File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -302,7 +302,9 @@ func TestAsyncTransport_FlushWithContext(t *testing.T) {
302302 })
303303
304304 t .Run ("timeout" , func (t * testing.T ) {
305+ blockChan := make (chan struct {})
305306 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
307+ <- blockChan
306308 w .WriteHeader (http .StatusOK )
307309 }))
308310 defer server .Close ()
@@ -314,11 +316,15 @@ func TestAsyncTransport_FlushWithContext(t *testing.T) {
314316 if ! ok {
315317 t .Fatalf ("expected *AsyncTransport, got %T" , tr )
316318 }
317- defer transport .Close ()
319+ defer func () {
320+ close (blockChan )
321+ transport .Close ()
322+ }()
323+
324+ _ = transport .SendEnvelope (testEnvelope (protocol .EnvelopeItemTypeEvent ))
318325
319- ctx , cancel := context .WithTimeout (context .Background (), 1 * time .Nanosecond )
326+ ctx , cancel := context .WithTimeout (context .Background (), 50 * time .Millisecond )
320327 defer cancel ()
321- time .Sleep (10 * time .Millisecond )
322328
323329 if transport .FlushWithContext (ctx ) {
324330 t .Error ("FlushWithContext should timeout" )
You can’t perform that action at this time.
0 commit comments