MCPcopy
hub / github.com/coder/websocket / TestWasm

Function TestWasm

ws_js_test.go:15–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestWasm(t *testing.T) {
16 t.Parallel()
17
18 ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
19 defer cancel()
20
21 c, resp, err := websocket.Dial(ctx, os.Getenv("WS_ECHO_SERVER_URL"), &websocket.DialOptions{
22 Subprotocols: []string{"echo"},
23 })
24 assert.Success(t, err)
25 defer c.Close(websocket.StatusInternalError, "")
26
27 assert.Equal(t, "subprotocol", "echo", c.Subprotocol())
28 assert.Equal(t, "response code", http.StatusSwitchingProtocols, resp.StatusCode)
29
30 c.SetReadLimit(65536)
31 for range 10 {
32 err = wstest.Echo(ctx, c, 65536)
33 assert.Success(t, err)
34 }
35
36 err = c.Close(websocket.StatusNormalClosure, "")
37 assert.Success(t, err)
38}
39
40func TestWasmDialTimeout(t *testing.T) {
41 t.Parallel()

Callers

nothing calls this directly

Calls 7

DialFunction · 0.92
SuccessFunction · 0.92
EqualFunction · 0.92
EchoFunction · 0.92
CloseMethod · 0.45
SubprotocolMethod · 0.45
SetReadLimitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…