(t *testing.T)
| 683 | } |
| 684 | |
| 685 | func TestDispatchSet(t *testing.T) { |
| 686 | uid := types.Uid(1) |
| 687 | s := test_makeSession(uid) |
| 688 | wg := sync.WaitGroup{} |
| 689 | r := responses{} |
| 690 | wg.Add(1) |
| 691 | go s.testWriteLoop(&r, &wg) |
| 692 | |
| 693 | destUid := types.Uid(2) |
| 694 | topicName := uid.P2PName(destUid) |
| 695 | |
| 696 | meta := make(chan *ClientComMessage, 1) |
| 697 | s.subs = make(map[string]*Subscription) |
| 698 | s.subs[topicName] = &Subscription{ |
| 699 | meta: meta, |
| 700 | } |
| 701 | |
| 702 | msg := &ClientComMessage{ |
| 703 | Set: &MsgClientSet{ |
| 704 | Id: "123", |
| 705 | Topic: destUid.UserId(), |
| 706 | MsgSetQuery: MsgSetQuery{ |
| 707 | Desc: &MsgSetDesc{}, |
| 708 | Sub: &MsgSetSub{}, |
| 709 | Tags: []string{"abc"}, |
| 710 | Cred: &MsgCredClient{}, |
| 711 | }, |
| 712 | }, |
| 713 | } |
| 714 | |
| 715 | s.dispatch(msg) |
| 716 | close(s.send) |
| 717 | wg.Wait() |
| 718 | |
| 719 | // Check we've routed the join request via the meta channel. |
| 720 | if len(r.messages) != 0 { |
| 721 | t.Errorf("responses: expected 0, received %d.", len(r.messages)) |
| 722 | } |
| 723 | if len(meta) == 1 { |
| 724 | req := <-meta |
| 725 | if req.sess != s { |
| 726 | t.Error("Set request: sess field expected to be the session under test.") |
| 727 | } |
| 728 | expectedWhat := constMsgMetaDesc | constMsgMetaSub | constMsgMetaTags | constMsgMetaCred |
| 729 | if msg.MetaWhat != expectedWhat { |
| 730 | t.Errorf("Set request what: expected %d vs %d", expectedWhat, msg.MetaWhat) |
| 731 | } |
| 732 | } else { |
| 733 | t.Errorf("Set messages: expected 1, received %d.", len(meta)) |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | func TestDispatchSetMalformedWhat(t *testing.T) { |
| 738 | uid := types.Uid(1) |
nothing calls this directly
no test coverage detected
searching dependent graphs…