Skip to content

Commit 65dfbdd

Browse files
committed
wasm: Add dial timeout test
1 parent 6840778 commit 65dfbdd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ws_js_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,19 @@ func TestWasm(t *testing.T) {
3636
err = c.Close(websocket.StatusNormalClosure, "")
3737
assert.Success(t, err)
3838
}
39+
40+
func TestWasmDialTimeout(t *testing.T) {
41+
t.Parallel()
42+
43+
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)
44+
defer cancel()
45+
46+
beforeDial := time.Now()
47+
_, _, err := websocket.Dial(ctx, "ws://example.com:9893", &websocket.DialOptions{
48+
Subprotocols: []string{"echo"},
49+
})
50+
assert.Error(t, err)
51+
if time.Since(beforeDial) >= time.Second {
52+
t.Fatal("wasm context dial timeout is not working", time.Since(beforeDial))
53+
}
54+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy