(t *testing.T)
| 1217 | } |
| 1218 | |
| 1219 | func TestHandleBroadcastPresInactiveTopic(t *testing.T) { |
| 1220 | topicName := "usrMe" |
| 1221 | numUsers := 1 |
| 1222 | helper := TopicTestHelper{} |
| 1223 | helper.setUp(t, numUsers, types.TopicCatMe, topicName, true) |
| 1224 | defer helper.tearDown() |
| 1225 | |
| 1226 | uid := helper.uids[0] |
| 1227 | srcUid := types.Uid(10) |
| 1228 | helper.topic.perSubs = make(map[string]perSubsData) |
| 1229 | helper.topic.perSubs[srcUid.UserId()] = perSubsData{enabled: true, online: false} |
| 1230 | |
| 1231 | msg := &ServerComMessage{ |
| 1232 | AsUser: uid.UserId(), |
| 1233 | RcptTo: uid.UserId(), |
| 1234 | Pres: &MsgServerPres{ |
| 1235 | Topic: "me", |
| 1236 | Src: srcUid.UserId(), |
| 1237 | What: "on", |
| 1238 | }, |
| 1239 | } |
| 1240 | |
| 1241 | // Deactivate topic. |
| 1242 | helper.topic.markDeleted() |
| 1243 | |
| 1244 | helper.topic.handleServerMsg(msg) |
| 1245 | helper.finish() |
| 1246 | |
| 1247 | // Check for errors from testHubLoop |
| 1248 | if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError { |
| 1249 | t.Fatal(errorMsgs[0].Ctrl.Text) |
| 1250 | } |
| 1251 | |
| 1252 | // Topic metadata. |
| 1253 | if online := helper.topic.perSubs[srcUid.UserId()].online; online { |
| 1254 | t.Errorf("User %s is expected to be offline.", srcUid.UserId()) |
| 1255 | } |
| 1256 | // Server messages. |
| 1257 | if len(helper.results[0].messages) != 0 { |
| 1258 | t.Fatalf("Session 0 is not expected to receive messages. Received %d.", len(helper.results[0].messages)) |
| 1259 | } |
| 1260 | if len(helper.hubMessages) != 0 { |
| 1261 | t.Errorf("Hubhelper.route isn't expected to receive messages. Received %d", len(helper.hubMessages)) |
| 1262 | } |
| 1263 | } |
| 1264 | |
| 1265 | const ( |
| 1266 | NoSub = 0 |
nothing calls this directly
no test coverage detected
searching dependent graphs…