(t *testing.T)
| 763 | } |
| 764 | |
| 765 | func TestHandleBroadcastInfoBogusNotification(t *testing.T) { |
| 766 | topicName := "usrP2P" |
| 767 | numUsers := 2 |
| 768 | helper := TopicTestHelper{} |
| 769 | helper.setUp(t, numUsers, types.TopicCatP2P, topicName, true) |
| 770 | defer helper.tearDown() |
| 771 | // Pretend we have 10 messages. |
| 772 | helper.topic.lastID = 10 |
| 773 | // uid1 notifies uid2 that uid1 has read messages up to seqid 11. |
| 774 | readId := 11 |
| 775 | from := helper.uids[0] |
| 776 | to := helper.uids[1] |
| 777 | |
| 778 | msg := &ClientComMessage{ |
| 779 | AsUser: from.UserId(), |
| 780 | Original: to.UserId(), |
| 781 | Note: &MsgClientNote{ |
| 782 | Topic: to.UserId(), |
| 783 | What: "read", |
| 784 | SeqId: readId, |
| 785 | }, |
| 786 | sess: helper.sessions[0], |
| 787 | } |
| 788 | helper.topic.handleClientMsg(msg) |
| 789 | helper.finish() |
| 790 | |
| 791 | // Check for errors from testHubLoop |
| 792 | if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError { |
| 793 | t.Fatal(errorMsgs[0].Ctrl.Text) |
| 794 | } |
| 795 | |
| 796 | // Read id should not be updated. |
| 797 | if actualReadId := helper.topic.perUser[from].readID; actualReadId != 0 { |
| 798 | t.Errorf("perUser[%s].readID: expected 0, found %d.", from.UserId(), actualReadId) |
| 799 | } |
| 800 | // Server messages. |
| 801 | for i, r := range helper.results { |
| 802 | if numMessages := len(r.messages); numMessages != 0 { |
| 803 | t.Errorf("User %d is not expected to receive any messages, %d received.", i, numMessages) |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | // Nothing should be routed through the hub. |
| 808 | if len(helper.hubMessages) != 0 { |
| 809 | t.Errorf("Hubhelper.route did not expect any messages, however %d received.", len(helper.hubMessages)) |
| 810 | } |
| 811 | } |
| 812 | |
| 813 | func TestHandleBroadcastInfoFilterOutRecvWithoutRPermission(t *testing.T) { |
| 814 | topicName := "usrP2P" |
nothing calls this directly
no test coverage detected
searching dependent graphs…