(t *testing.T)
| 970 | } |
| 971 | |
| 972 | func TestHandleBroadcastInfoDbError(t *testing.T) { |
| 973 | topicName := "usrP2P" |
| 974 | numUsers := 2 |
| 975 | helper := TopicTestHelper{} |
| 976 | helper.setUp(t, numUsers, types.TopicCatP2P, topicName, true) |
| 977 | defer helper.tearDown() |
| 978 | // Pretend we have 10 messages. |
| 979 | helper.topic.lastID = 10 |
| 980 | // uid1 notifies uid2 that uid1 has read messages up to seqid 11. |
| 981 | readId := 8 |
| 982 | from := helper.uids[0] |
| 983 | to := helper.uids[1] |
| 984 | |
| 985 | helper.ss.EXPECT().Update(topicName, from, map[string]any{"ReadSeqId": readId}).Return(types.ErrInternal) |
| 986 | |
| 987 | msg := &ClientComMessage{ |
| 988 | AsUser: from.UserId(), |
| 989 | Original: to.UserId(), |
| 990 | Note: &MsgClientNote{ |
| 991 | Topic: to.UserId(), |
| 992 | What: "read", |
| 993 | SeqId: readId, |
| 994 | }, |
| 995 | sess: helper.sessions[0], |
| 996 | } |
| 997 | helper.topic.handleClientMsg(msg) |
| 998 | helper.finish() |
| 999 | |
| 1000 | // Check for errors from testHubLoop |
| 1001 | if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError { |
| 1002 | t.Fatal(errorMsgs[0].Ctrl.Text) |
| 1003 | } |
| 1004 | |
| 1005 | // Read id should not be updated. |
| 1006 | if actualReadId := helper.topic.perUser[from].readID; actualReadId != 0 { |
| 1007 | t.Errorf("perUser[%s].readID: expected 0, found %d.", from.UserId(), actualReadId) |
| 1008 | } |
| 1009 | // Server messages. |
| 1010 | for i, r := range helper.results { |
| 1011 | if numMessages := len(r.messages); numMessages != 0 { |
| 1012 | t.Errorf("User %d is not expected to receive any messages, %d received.", i, numMessages) |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | // Nothing should be routed through the hub. |
| 1017 | if len(helper.hubMessages) != 0 { |
| 1018 | t.Errorf("Hubhelper.route did not expect any messages, however %d received.", len(helper.hubMessages)) |
| 1019 | } |
| 1020 | } |
| 1021 | |
| 1022 | func TestHandleBroadcastInfoInvalidChannelAccess(t *testing.T) { |
| 1023 | topicName := "grpTest" |
nothing calls this directly
no test coverage detected
searching dependent graphs…