MCPcopy
hub / github.com/daptin/daptin / TestWebSocketNoSuchMethod

Function TestWebSocketNoSuchMethod

websocket_test.go:509–528  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

507}
508
509func TestWebSocketNoSuchMethod(t *testing.T) {
510 ensureServer()
511 token := signUpAndGetToken(t)
512
513 ws := dialWS(t, token)
514 defer ws.Close()
515
516 id := nextReqId()
517 sendJSON(t, ws, wsPayload{Id: id, Method: "nonexistent-method", Payload: map[string]interface{}{}})
518 msg := recvJSON(t, ws, 5*time.Second)
519 if msg.Type != "response" || msg.Ok == nil || *msg.Ok {
520 t.Errorf("expected error for unknown method, got type=%q ok=%v", msg.Type, msg.Ok)
521 }
522 if msg.Error != "no such method" {
523 t.Errorf("expected error='no such method', got %q", msg.Error)
524 }
525 if msg.Method != "nonexistent-method" {
526 t.Errorf("expected method echoed back, got %q", msg.Method)
527 }
528}
529
530func TestWebSocketRequestCorrelation(t *testing.T) {
531 ensureServer()

Callers

nothing calls this directly

Calls 7

ensureServerFunction · 0.85
signUpAndGetTokenFunction · 0.85
dialWSFunction · 0.85
nextReqIdFunction · 0.85
sendJSONFunction · 0.85
recvJSONFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected