MCPcopy
hub / github.com/daptin/daptin / TestWebSocketSessionOpen

Function TestWebSocketSessionOpen

websocket_test.go:190–215  ·  view source on GitHub ↗

===== E2E TESTS =====

(t *testing.T)

Source from the content-addressed store, hash-verified

188// ===== E2E TESTS =====
189
190func TestWebSocketSessionOpen(t *testing.T) {
191 ensureServer()
192 token := signUpAndGetToken(t)
193
194 ws := dialWSRaw(t, token)
195 defer ws.Close()
196
197 // first message should be session-open
198 msg := recvJSON(t, ws, 5*time.Second)
199 if msg.Type != "session" {
200 t.Errorf("expected type=session, got %q", msg.Type)
201 }
202 if msg.Status != "open" {
203 t.Errorf("expected status=open, got %q", msg.Status)
204 }
205
206 var data map[string]interface{}
207 json.Unmarshal(msg.Data, &data)
208 if data["user"] == nil {
209 t.Errorf("session-open missing user field")
210 }
211 if data["sessionId"] == nil {
212 t.Errorf("session-open missing sessionId field")
213 }
214 t.Logf("session-open: user=%v sessionId=%v", data["user"], data["sessionId"])
215}
216
217func TestWebSocketConnect(t *testing.T) {
218 ensureServer()

Callers

nothing calls this directly

Calls 5

ensureServerFunction · 0.85
signUpAndGetTokenFunction · 0.85
dialWSRawFunction · 0.85
recvJSONFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected