MCPcopy Index your code
hub / github.com/tinode/chat / TestDispatchGet

Function TestDispatchGet

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

Source from the content-addressed store, hash-verified

576}
577
578func TestDispatchGet(t *testing.T) {
579 uid := types.Uid(1)
580 s := test_makeSession(uid)
581 wg := sync.WaitGroup{}
582 r := responses{}
583 wg.Add(1)
584 go s.testWriteLoop(&r, &wg)
585
586 destUid := types.Uid(2)
587 topicName := uid.P2PName(destUid)
588
589 meta := make(chan *ClientComMessage, 1)
590 s.subs = make(map[string]*Subscription)
591 s.subs[topicName] = &Subscription{
592 meta: meta,
593 }
594
595 msg := &ClientComMessage{
596 Get: &MsgClientGet{
597 Id: "123",
598 Topic: destUid.UserId(),
599 MsgGetQuery: MsgGetQuery{
600 What: "desc sub del cred",
601 },
602 },
603 }
604
605 s.dispatch(msg)
606 close(s.send)
607 wg.Wait()
608
609 // Check we've routed the join request via the meta channel.
610 if len(r.messages) != 0 {
611 t.Errorf("responses: expected 0, received %d.", len(r.messages))
612 }
613 if len(meta) == 1 {
614 req := <-meta
615 if req.sess != s {
616 t.Error("Get request: sess field expected to be the session under test.")
617 }
618 } else {
619 t.Errorf("Get messages: expected 1, received %d.", len(meta))
620 }
621}
622
623func TestDispatchGetMalformedWhat(t *testing.T) {
624 uid := types.Uid(1)

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…