Skip to content
This repository was archived by the owner on Nov 7, 2022. It is now read-only.

Commit 2277311

Browse files
committed
Fix stream testing for Go v1.11
* Test stream server HandleFunc's stream an expected message and then return an HTTP error response code to break stream retrying, so received messages can be checked * Tests erroneously used 130 as the HTTP error response code (130 is the Twitter code). Starting in Go v1.11, such invalid HTTP response codes cause the connection to the test stream server to hang, causing tests to hang. * Fix the error code to be 500, some valid HTTP status code that isn't handled specially (e.g. no backoff)
1 parent 856367c commit 2277311

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

twitter/streams_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func TestStream_Filter(t *testing.T) {
106106
)
107107
default:
108108
// Only allow first request
109-
http.Error(w, "Stream API not available!", 130)
109+
http.Error(w, "Stream API not available!", 500)
110110
}
111111
reqCount++
112112
})
@@ -146,7 +146,7 @@ func TestStream_Sample(t *testing.T) {
146146
)
147147
default:
148148
// Only allow first request
149-
http.Error(w, "Stream API not available!", 130)
149+
http.Error(w, "Stream API not available!", 500)
150150
}
151151
reqCount++
152152
})
@@ -183,7 +183,7 @@ func TestStream_User(t *testing.T) {
183183
fmt.Fprintf(w, `{"friends": [666024290140217347, 666024290140217349, 666024290140217342]}`+"\r\n"+"\r\n")
184184
default:
185185
// Only allow first request
186-
http.Error(w, "Stream API not available!", 130)
186+
http.Error(w, "Stream API not available!", 500)
187187
}
188188
reqCount++
189189
})
@@ -223,7 +223,7 @@ func TestStream_User_TooManyFriends(t *testing.T) {
223223
fmt.Fprintf(w, `{"friends": %s}`+"\r\n"+"\r\n", friendsList)
224224
default:
225225
// Only allow first request
226-
http.Error(w, "Stream API not available!", 130)
226+
http.Error(w, "Stream API not available!", 500)
227227
}
228228
reqCount++
229229
})
@@ -264,7 +264,7 @@ func TestStream_Site(t *testing.T) {
264264
)
265265
default:
266266
// Only allow first request
267-
http.Error(w, "Stream API not available!", 130)
267+
http.Error(w, "Stream API not available!", 500)
268268
}
269269
reqCount++
270270
})
@@ -304,7 +304,7 @@ func TestStream_PublicFirehose(t *testing.T) {
304304
)
305305
default:
306306
// Only allow first request
307-
http.Error(w, "Stream API not available!", 130)
307+
http.Error(w, "Stream API not available!", 500)
308308
}
309309
reqCount++
310310
})
@@ -337,7 +337,7 @@ func TestStreamRetry_ExponentialBackoff(t *testing.T) {
337337
http.Error(w, "Service Unavailable", 503)
338338
default:
339339
// Only allow first request
340-
http.Error(w, "Stream API not available!", 130)
340+
http.Error(w, "Stream API not available!", 500)
341341
}
342342
reqCount++
343343
})
@@ -371,7 +371,7 @@ func TestStreamRetry_AggressiveBackoff(t *testing.T) {
371371
http.Error(w, "Too Many Requests", 429)
372372
default:
373373
// Only allow first request
374-
http.Error(w, "Stream API not available!", 130)
374+
http.Error(w, "Stream API not available!", 500)
375375
}
376376
reqCount++
377377
})

0 commit comments

Comments
 (0)