MCPcopy
hub / github.com/daptin/daptin / TestWebSocketSubscribeNonexistentTopicError

Function TestWebSocketSubscribeNonexistentTopicError

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

Source from the content-addressed store, hash-verified

277}
278
279func TestWebSocketSubscribeNonexistentTopicError(t *testing.T) {
280 ensureServer()
281 token := signUpAndGetToken(t)
282
283 ws := dialWS(t, token)
284 defer ws.Close()
285
286 id := nextReqId()
287 sendJSON(t, ws, wsPayload{
288 Id: id,
289 Method: "subscribe",
290 Payload: map[string]interface{}{"topicName": "nonexistent_topic_xyz_12345"},
291 })
292
293 msg := recvJSON(t, ws, 5*time.Second)
294 if msg.Type != "response" {
295 t.Errorf("expected type=response, got %q", msg.Type)
296 }
297 if msg.Ok == nil || *msg.Ok {
298 t.Errorf("expected ok=false, got %v", msg.Ok)
299 }
300 if msg.Method != "subscribe" {
301 t.Errorf("expected method=subscribe, got %q", msg.Method)
302 }
303}
304
305func TestWebSocketUnsubscribeAck(t *testing.T) {
306 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