@@ -46,7 +46,7 @@ const dockerEndpoint = "/var/run/docker.sock"
46
46
47
47
// Close closes the underlying connection. Implement Close() in this file
48
48
// as ClientServerImpl doesn't implement it. This is needed by the
49
- // TestSetReadDeadline* tests
49
+ // TestSetReadDeadline* tests.
50
50
func (cs * ClientServerImpl ) Close () error {
51
51
return cs .Disconnect ()
52
52
}
@@ -57,15 +57,15 @@ func TestClientProxy(t *testing.T) {
57
57
defer os .Unsetenv ("HTTP_PROXY" )
58
58
59
59
types := []interface {}{ecsacs.AckRequest {}}
60
- cs := getClientServer ("http://www.amazon.com" , types )
60
+ cs := getTestClientServer ("http://www.amazon.com" , types )
61
61
err := cs .Connect ()
62
62
assert .Error (t , err )
63
63
assert .True (t , strings .Contains (err .Error (), proxy_url ), "proxy not found: %s" , err .Error ())
64
64
}
65
65
66
66
// TestConcurrentWritesDontPanic will force a panic in the websocket library if
67
- // the implemented methods don't handle concurrency correctly
68
- // See https://godoc.org/github.com/gorilla/websocket#hdr-Concurrency
67
+ // the implemented methods don't handle concurrency correctly.
68
+ // See https://godoc.org/github.com/gorilla/websocket#hdr-Concurrency.
69
69
func TestConcurrentWritesDontPanic (t * testing.T ) {
70
70
closeWS := make (chan []byte )
71
71
defer close (closeWS )
@@ -86,7 +86,7 @@ func TestConcurrentWritesDontPanic(t *testing.T) {
86
86
req := ecsacs.AckRequest {Cluster : aws .String ("test" ), ContainerInstance : aws .String ("test" ), MessageId : aws .String ("test" )}
87
87
88
88
types := []interface {}{ecsacs.AckRequest {}}
89
- cs := getClientServer (mockServer .URL , types )
89
+ cs := getTestClientServer (mockServer .URL , types )
90
90
require .NoError (t , cs .Connect ())
91
91
92
92
executeTenRequests := func () {
@@ -96,16 +96,15 @@ func TestConcurrentWritesDontPanic(t *testing.T) {
96
96
}
97
97
98
98
// Make requests from two separate routines to try and force a
99
- // concurrent write
99
+ // concurrent write.
100
100
go executeTenRequests ()
101
101
go executeTenRequests ()
102
102
103
103
t .Log ("Waiting for all 20 requests to succeed" )
104
104
waitForRequests .Wait ()
105
105
}
106
106
107
- func getClientServer (url string , msgType []interface {}) * ClientServerImpl {
108
-
107
+ func getTestClientServer (url string , msgType []interface {}) * ClientServerImpl {
109
108
testCreds := credentials .NewStaticCredentials ("test-id" , "test-secret" , "test-token" )
110
109
111
110
return & ClientServerImpl {
@@ -124,7 +123,7 @@ func getClientServer(url string, msgType []interface{}) *ClientServerImpl {
124
123
}
125
124
126
125
// TestProxyVariableCustomValue ensures that a user is able to override the
127
- // proxy variable by setting an environment variable
126
+ // proxy variable by setting an environment variable.
128
127
func TestProxyVariableCustomValue (t * testing.T ) {
129
128
closeWS := make (chan []byte )
130
129
defer close (closeWS )
@@ -136,13 +135,13 @@ func TestProxyVariableCustomValue(t *testing.T) {
136
135
testString := "Custom no proxy string"
137
136
os .Setenv ("NO_PROXY" , testString )
138
137
types := []interface {}{ecsacs.AckRequest {}}
139
- require .NoError (t , getClientServer (mockServer .URL , types ).Connect ())
138
+ require .NoError (t , getTestClientServer (mockServer .URL , types ).Connect ())
140
139
141
140
assert .Equal (t , os .Getenv ("NO_PROXY" ), testString , "NO_PROXY should match user-supplied variable" )
142
141
}
143
142
144
143
// TestProxyVariableDefaultValue verifies that NO_PROXY gets overridden if it
145
- // isn't already set
144
+ // isn't already set.
146
145
func TestProxyVariableDefaultValue (t * testing.T ) {
147
146
closeWS := make (chan []byte )
148
147
defer close (closeWS )
@@ -153,15 +152,15 @@ func TestProxyVariableDefaultValue(t *testing.T) {
153
152
154
153
os .Unsetenv ("NO_PROXY" )
155
154
types := []interface {}{ecsacs.AckRequest {}}
156
- getClientServer (mockServer .URL , types ).Connect ()
155
+ getTestClientServer (mockServer .URL , types ).Connect ()
157
156
158
157
expectedEnvVar := "169.254.169.254,169.254.170.2," + dockerEndpoint
159
158
160
159
assert .Equal (t , os .Getenv ("NO_PROXY" ), expectedEnvVar , "Variable NO_PROXY expected to be overwritten when no default value supplied" )
161
160
}
162
161
163
162
// TestHandleMessagePermissibleCloseCode ensures that permissible close codes
164
- // are wrapped in io.EOF
163
+ // are wrapped in io.EOF.
165
164
func TestHandleMessagePermissibleCloseCode (t * testing.T ) {
166
165
closeWS := make (chan []byte )
167
166
defer close (closeWS )
@@ -172,7 +171,7 @@ func TestHandleMessagePermissibleCloseCode(t *testing.T) {
172
171
mockServer .StartTLS ()
173
172
174
173
types := []interface {}{ecsacs.AckRequest {}}
175
- cs := getClientServer (mockServer .URL , types )
174
+ cs := getTestClientServer (mockServer .URL , types )
176
175
require .NoError (t , cs .Connect ())
177
176
assert .True (t , cs .IsReady (), "expected websocket connection to be ready" )
178
177
@@ -185,7 +184,7 @@ func TestHandleMessagePermissibleCloseCode(t *testing.T) {
185
184
}
186
185
187
186
// TestHandleMessageUnexpectedCloseCode checks that unexpected close codes will
188
- // be returned as is (not wrapped in io.EOF)
187
+ // be returned as is (not wrapped in io.EOF).
189
188
func TestHandleMessageUnexpectedCloseCode (t * testing.T ) {
190
189
closeWS := make (chan []byte )
191
190
defer close (closeWS )
@@ -195,7 +194,7 @@ func TestHandleMessageUnexpectedCloseCode(t *testing.T) {
195
194
mockServer .StartTLS ()
196
195
197
196
types := []interface {}{ecsacs.AckRequest {}}
198
- cs := getClientServer (mockServer .URL , types )
197
+ cs := getTestClientServer (mockServer .URL , types )
199
198
require .NoError (t , cs .Connect ())
200
199
assert .True (t , cs .IsReady (), "expected websocket connection to be ready" )
201
200
@@ -209,7 +208,7 @@ func TestHandleMessageUnexpectedCloseCode(t *testing.T) {
209
208
}
210
209
211
210
// TestHandlNonHTTPSEndpoint verifies that the wsclient can handle communication over
212
- // an HTTP (so WS) connection
211
+ // an HTTP (so WS) connection.
213
212
func TestHandleNonHTTPSEndpoint (t * testing.T ) {
214
213
closeWS := make (chan []byte )
215
214
defer close (closeWS )
@@ -219,7 +218,7 @@ func TestHandleNonHTTPSEndpoint(t *testing.T) {
219
218
defer mockServer .Close ()
220
219
221
220
types := []interface {}{ecsacs.AckRequest {}}
222
- cs := getClientServer (mockServer .URL , types )
221
+ cs := getTestClientServer (mockServer .URL , types )
223
222
require .NoError (t , cs .Connect ())
224
223
assert .True (t , cs .IsReady (), "expected websocket connection to be ready" )
225
224
@@ -231,7 +230,7 @@ func TestHandleNonHTTPSEndpoint(t *testing.T) {
231
230
}
232
231
233
232
// TestHandleIncorrectHttpScheme checks that an incorrect URL scheme results in
234
- // an error
233
+ // an error.
235
234
func TestHandleIncorrectURLScheme (t * testing.T ) {
236
235
closeWS := make (chan []byte )
237
236
defer close (closeWS )
@@ -244,16 +243,16 @@ func TestHandleIncorrectURLScheme(t *testing.T) {
244
243
mockServerURL .Scheme = "notaparticularlyrealscheme"
245
244
246
245
types := []interface {}{ecsacs.AckRequest {}}
247
- cs := getClientServer (mockServerURL .String (), types )
246
+ cs := getTestClientServer (mockServerURL .String (), types )
248
247
err := cs .Connect ()
249
248
250
249
assert .Error (t , err , "Expected error for incorrect URL scheme" )
251
250
}
252
251
253
252
// TestWebsocketScheme checks that websocketScheme handles valid and invalid mappings
254
- // correctly
253
+ // correctly.
255
254
func TestWebsocketScheme (t * testing.T ) {
256
- // test valid schemes
255
+ // Test valid schemes.
257
256
validMappings := map [string ]string {
258
257
"http" : "ws" ,
259
258
"https" : "wss" ,
@@ -266,7 +265,7 @@ func TestWebsocketScheme(t *testing.T) {
266
265
assert .Equal (t , actualOutput , expectedOutput , "Valid http schemes should map to a websocket scheme" )
267
266
}
268
267
269
- // test an invalid mapping
268
+ // Test an invalid mapping.
270
269
_ , err := websocketScheme ("highly-likely-to-be-junk" )
271
270
assert .Error (t , err , "Expected error for invalid http scheme" )
272
271
}
@@ -322,7 +321,7 @@ func TestAddRequestPayloadHandler(t *testing.T) {
322
321
323
322
types := []interface {}{ecsacs.PayloadMessage {}}
324
323
messageError := make (chan error )
325
- cs := getClientServer (mockServer .URL , types )
324
+ cs := getTestClientServer (mockServer .URL , types )
326
325
cs .conn = conn
327
326
328
327
defer cs .Close ()
@@ -365,7 +364,7 @@ func TestMakeUnrecognizedRequest(t *testing.T) {
365
364
mockServer .StartTLS ()
366
365
367
366
types := []interface {}{ecsacs.PayloadMessage {}}
368
- cs := getClientServer (mockServer .URL , types )
367
+ cs := getTestClientServer (mockServer .URL , types )
369
368
cs .conn = conn
370
369
371
370
defer cs .Close ()
@@ -389,7 +388,7 @@ func TestWriteCloseMessage(t *testing.T) {
389
388
mockServer .StartTLS ()
390
389
391
390
types := []interface {}{ecsacs.PayloadMessage {}}
392
- cs := getClientServer (mockServer .URL , types )
391
+ cs := getTestClientServer (mockServer .URL , types )
393
392
cs .Connect ()
394
393
395
394
defer cs .Close ()
0 commit comments