@@ -32,7 +32,7 @@ import (
32
32
"github.com/facebook/fbthrift/thrift/lib/go/thrift/types"
33
33
)
34
34
35
- func TestClient (t * testing.T ) {
35
+ func TestNewClientConnectionScenarios (t * testing.T ) {
36
36
listener , err := net .Listen ("tcp" , ":0" )
37
37
if err != nil {
38
38
t .Fatalf ("failed to listen: %v" , err )
@@ -48,7 +48,7 @@ func TestClient(t *testing.T) {
48
48
addr := listener .Addr ()
49
49
50
50
// Testing successful client connection
51
- client , err := DeprecatedNewClient (
51
+ client , err := NewClient (
52
52
WithRocket (),
53
53
WithIoTimeout (time .Second ),
54
54
WithProtocolID (types .ProtocolIDCompact ),
@@ -67,7 +67,7 @@ func TestClient(t *testing.T) {
67
67
}
68
68
69
69
// Testing unsuccessful client connection (cannot connect at all)
70
- client , err = DeprecatedNewClient (
70
+ client , err = NewClient (
71
71
WithRocket (),
72
72
WithDialer (func () (net.Conn , error ) {
73
73
return net .Dial ("unix" , "/tmp/non_existent_garbage_socket_12345" )
@@ -83,7 +83,7 @@ func TestClient(t *testing.T) {
83
83
if err != nil {
84
84
t .Fatal (fmt .Sprintf ("failed to get FD count: %#v" , err ))
85
85
}
86
- client , err = DeprecatedNewClient (
86
+ client , err = NewClient (
87
87
WithRocket (),
88
88
// Invalid protocol that intentionally breaks client creation
89
89
WithProtocolID (types .ProtocolID (12345 )),
@@ -96,7 +96,7 @@ func TestClient(t *testing.T) {
96
96
t .Fatalf ("unexpected error when creating client: %v" , err )
97
97
}
98
98
// IMPORTANT!
99
- // Even though we perform an explicit call to Close() in DeprecatedNewClient ()
99
+ // Even though we perform an explicit call to Close() in NewClient ()
100
100
// upon protocol error, actual FD closing is done by the garbage collector.
101
101
// Without the GC call below - the FD may still linger and affect test results.
102
102
runtime .GC ()
@@ -131,7 +131,7 @@ func getNumFileDesciptors() (int, error) {
131
131
return len (files ), nil
132
132
}
133
133
134
- func TestClientV2 (t * testing.T ) {
134
+ func TestNewClientCreation (t * testing.T ) {
135
135
listener , err := net .Listen ("tcp" , ":0" )
136
136
if err != nil {
137
137
t .Fatalf ("failed to listen: %v" , err )
@@ -153,6 +153,9 @@ func TestClientV2(t *testing.T) {
153
153
return net .Dial (addr .Network (), addr .String ())
154
154
}),
155
155
)
156
+ if _ , ok := channel .(* rocketClient ); ! ok {
157
+ t .Fatalf ("channel is not of the correct underlying type" )
158
+ }
156
159
if err != nil {
157
160
t .Fatalf ("failed to create client: %v" , err )
158
161
}
@@ -169,6 +172,9 @@ func TestClientV2(t *testing.T) {
169
172
return net .Dial (addr .Network (), addr .String ())
170
173
}),
171
174
)
175
+ if _ , ok := channel .(* SerialChannel ); ! ok {
176
+ t .Fatalf ("channel is not of the correct underlying type" )
177
+ }
172
178
if err != nil {
173
179
t .Fatalf ("failed to create client: %v" , err )
174
180
}
@@ -185,6 +191,9 @@ func TestClientV2(t *testing.T) {
185
191
return net .Dial (addr .Network (), addr .String ())
186
192
}),
187
193
)
194
+ if _ , ok := channel .(* SerialChannel ); ! ok {
195
+ t .Fatalf ("channel is not of the correct underlying type" )
196
+ }
188
197
if err != nil {
189
198
t .Fatalf ("failed to create client: %v" , err )
190
199
}
0 commit comments