@@ -109,7 +109,7 @@ func TestConnection(t *testing.T) {
109
109
t .Run ("completed context" , func (t * testing.T ) {
110
110
ctx , cancel := context .WithCancel (context .Background ())
111
111
cancel ()
112
- conn := & connection {id : "foobar" , nc : & net.TCPConn {}}
112
+ conn := & connection {id : "foobar" , nc : & net.TCPConn {}, connected : connected }
113
113
want := ConnectionError {ConnectionID : "foobar" , Wrapped : ctx .Err (), message : "failed to write" }
114
114
got := conn .writeWireMessage (ctx , []byte {})
115
115
if ! cmp .Equal (got , want , cmp .Comparer (compareErrors )) {
@@ -144,7 +144,7 @@ func TestConnection(t *testing.T) {
144
144
message : "failed to set write deadline" ,
145
145
}
146
146
tnc := & testNetConn {deadlineerr : errors .New ("set writeDeadline error" )}
147
- conn := & connection {id : "foobar" , nc : tnc , writeTimeout : tc .timeout }
147
+ conn := & connection {id : "foobar" , nc : tnc , writeTimeout : tc .timeout , connected : connected }
148
148
got := conn .writeWireMessage (ctx , []byte {})
149
149
if ! cmp .Equal (got , want , cmp .Comparer (compareErrors )) {
150
150
t .Errorf ("errors do not match. got %v; want %v" , got , want )
@@ -160,7 +160,7 @@ func TestConnection(t *testing.T) {
160
160
err := errors .New ("Write error" )
161
161
want := ConnectionError {ConnectionID : "foobar" , Wrapped : err , message : "unable to write wire message to network" }
162
162
tnc := & testNetConn {writeerr : err }
163
- conn := & connection {id : "foobar" , nc : tnc }
163
+ conn := & connection {id : "foobar" , nc : tnc , connected : connected }
164
164
got := conn .writeWireMessage (context .Background (), []byte {})
165
165
if ! cmp .Equal (got , want , cmp .Comparer (compareErrors )) {
166
166
t .Errorf ("errors do not match. got %v; want %v" , got , want )
@@ -170,7 +170,7 @@ func TestConnection(t *testing.T) {
170
170
}
171
171
})
172
172
tnc := & testNetConn {}
173
- conn := & connection {id : "foobar" , nc : tnc }
173
+ conn := & connection {id : "foobar" , nc : tnc , connected : connected }
174
174
want := []byte {0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A }
175
175
err := conn .writeWireMessage (context .Background (), want )
176
176
noerr (t , err )
@@ -192,7 +192,7 @@ func TestConnection(t *testing.T) {
192
192
t .Run ("completed context" , func (t * testing.T ) {
193
193
ctx , cancel := context .WithCancel (context .Background ())
194
194
cancel ()
195
- conn := & connection {id : "foobar" , nc : & net.TCPConn {}}
195
+ conn := & connection {id : "foobar" , nc : & net.TCPConn {}, connected : connected }
196
196
want := ConnectionError {ConnectionID : "foobar" , Wrapped : ctx .Err (), message : "failed to read" }
197
197
_ , got := conn .readWireMessage (ctx , []byte {})
198
198
if ! cmp .Equal (got , want , cmp .Comparer (compareErrors )) {
@@ -227,7 +227,7 @@ func TestConnection(t *testing.T) {
227
227
message : "failed to set read deadline" ,
228
228
}
229
229
tnc := & testNetConn {deadlineerr : errors .New ("set readDeadline error" )}
230
- conn := & connection {id : "foobar" , nc : tnc , readTimeout : tc .timeout }
230
+ conn := & connection {id : "foobar" , nc : tnc , readTimeout : tc .timeout , connected : connected }
231
231
_ , got := conn .readWireMessage (ctx , []byte {})
232
232
if ! cmp .Equal (got , want , cmp .Comparer (compareErrors )) {
233
233
t .Errorf ("errors do not match. got %v; want %v" , got , want )
@@ -242,7 +242,7 @@ func TestConnection(t *testing.T) {
242
242
err := errors .New ("Read error" )
243
243
want := ConnectionError {ConnectionID : "foobar" , Wrapped : err , message : "unable to decode message length" }
244
244
tnc := & testNetConn {readerr : err }
245
- conn := & connection {id : "foobar" , nc : tnc }
245
+ conn := & connection {id : "foobar" , nc : tnc , connected : connected }
246
246
_ , got := conn .readWireMessage (context .Background (), []byte {})
247
247
if ! cmp .Equal (got , want , cmp .Comparer (compareErrors )) {
248
248
t .Errorf ("errors do not match. got %v; want %v" , got , want )
@@ -255,7 +255,7 @@ func TestConnection(t *testing.T) {
255
255
err := errors .New ("Read error" )
256
256
want := ConnectionError {ConnectionID : "foobar" , Wrapped : err , message : "unable to read full message" }
257
257
tnc := & testNetConn {readerr : err , buf : []byte {0x11 , 0x00 , 0x00 , 0x00 }}
258
- conn := & connection {id : "foobar" , nc : tnc }
258
+ conn := & connection {id : "foobar" , nc : tnc , connected : connected }
259
259
_ , got := conn .readWireMessage (context .Background (), []byte {})
260
260
if ! cmp .Equal (got , want , cmp .Comparer (compareErrors )) {
261
261
t .Errorf ("errors do not match. got %v; want %v" , got , want )
@@ -268,7 +268,7 @@ func TestConnection(t *testing.T) {
268
268
want := []byte {0x0A , 0x00 , 0x00 , 0x00 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A }
269
269
tnc := & testNetConn {buf : make ([]byte , len (want ))}
270
270
copy (tnc .buf , want )
271
- conn := & connection {id : "foobar" , nc : tnc }
271
+ conn := & connection {id : "foobar" , nc : tnc , connected : connected }
272
272
got , err := conn .readWireMessage (context .Background (), nil )
273
273
noerr (t , err )
274
274
if ! cmp .Equal (got , want ) {
0 commit comments