(t *testing.T)
| 576 | } |
| 577 | |
| 578 | func 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 | |
| 623 | func TestDispatchGetMalformedWhat(t *testing.T) { |
| 624 | uid := types.Uid(1) |
nothing calls this directly
no test coverage detected
searching dependent graphs…