MCPcopy
hub / github.com/daptin/daptin / TestWebSocketCreateDuplicateTopicError

Function TestWebSocketCreateDuplicateTopicError

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

Source from the content-addressed store, hash-verified

417}
418
419func TestWebSocketCreateDuplicateTopicError(t *testing.T) {
420 ensureServer()
421 token := signUpAndGetToken(t)
422
423 ws := dialWS(t, token)
424 defer ws.Close()
425
426 topicName := fmt.Sprintf("dup-topic-%d", time.Now().UnixNano())
427
428 // create first
429 sendJSON(t, ws, wsPayload{Id: nextReqId(), Method: "create-topicName", Payload: map[string]interface{}{"name": topicName}})
430 recvJSON(t, ws, 5*time.Second) // success response
431
432 // create duplicate
433 sendJSON(t, ws, wsPayload{Id: nextReqId(), Method: "create-topicName", Payload: map[string]interface{}{"name": topicName}})
434 msg := recvJSON(t, ws, 5*time.Second)
435 if msg.Type != "response" || msg.Ok == nil || *msg.Ok {
436 t.Errorf("expected error for duplicate topic, got type=%q ok=%v", msg.Type, msg.Ok)
437 }
438}
439
440func TestWebSocketPingPong(t *testing.T) {
441 ensureServer()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected