MCPcopy
hub / github.com/tinode/chat / TestDispatchLeaveUnsubMe

Function TestDispatchLeaveUnsubMe

server/session_test.go:384–409  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

382}
383
384func TestDispatchLeaveUnsubMe(t *testing.T) {
385 uid := types.Uid(1)
386 s := test_makeSession(uid)
387 wg := sync.WaitGroup{}
388 r := responses{}
389 wg.Add(1)
390 go s.testWriteLoop(&r, &wg)
391
392 s.subs = make(map[string]*Subscription)
393 s.subs[uid.UserId()] = &Subscription{}
394
395 msg := &ClientComMessage{
396 Leave: &MsgClientLeave{
397 Id: "123",
398 // Cannot unsubscribe from 'me'.
399 Topic: "me",
400 Unsub: true,
401 },
402 }
403
404 s.dispatch(msg)
405 close(s.send)
406 wg.Wait()
407
408 verifyResponseCodes(&r, []int{http.StatusForbidden}, t)
409}
410
411func TestDispatchLeaveUnknownTopic(t *testing.T) {
412 uid := types.Uid(1)

Callers

nothing calls this directly

Calls 8

UidTypeAlias · 0.92
test_makeSessionFunction · 0.85
verifyResponseCodesFunction · 0.85
testWriteLoopMethod · 0.80
UserIdMethod · 0.80
dispatchMethod · 0.80
WaitMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…