MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / dialWSPath

Function dialWSPath

internal/ws/handler_test.go:76–91  ·  view source on GitHub ↗

dialWSPath connects to a specific WS path on the test server, authenticating with the Authorization: Bearer header (the credential is never in the URL).

(t *testing.T, srv *httptest.Server, path, token string)

Source from the content-addressed store, hash-verified

74// dialWSPath connects to a specific WS path on the test server, authenticating
75// with the Authorization: Bearer header (the credential is never in the URL).
76func dialWSPath(t *testing.T, srv *httptest.Server, path, token string) (*websocket.Conn, *http.Response) {
77 t.Helper()
78 url := fmt.Sprintf("ws%s%s", strings.TrimPrefix(srv.URL, "http"), path)
79 ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
80 defer cancel()
81 opts := &websocket.DialOptions{HTTPHeader: http.Header{}}
82 if token != "" {
83 opts.HTTPHeader.Set("Authorization", "Bearer "+token)
84 }
85 conn, resp, err := websocket.Dial(ctx, url, opts)
86 if err != nil {
87 // Return nil conn for error-path tests
88 return nil, resp
89 }
90 return conn, resp
91}
92
93// dialWS connects to the versioned WS endpoint.
94func dialWS(t *testing.T, srv *httptest.Server, email, token string) (*websocket.Conn, *http.Response) {

Callers 1

dialWSFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected