MCPcopy
hub / github.com/tinode/chat / TestRegisterSessionInactiveTopic

Function TestRegisterSessionInactiveTopic

server/topic_test.go:1470–1517  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1468}
1469
1470func TestRegisterSessionInactiveTopic(t *testing.T) {
1471 topicName := "usrMe"
1472 numUsers := 1
1473 helper := TopicTestHelper{}
1474 helper.setUp(t, numUsers, types.TopicCatMe, topicName, false)
1475 defer helper.tearDown()
1476 if len(helper.topic.sessions) != 0 {
1477 helper.finish()
1478 t.Fatalf("Initially attached sessions: expected 0 vs found %d", len(helper.topic.sessions))
1479 }
1480
1481 uid := helper.uids[0]
1482
1483 s := helper.sessions[0]
1484 join := &ClientComMessage{
1485 Sub: &MsgClientSub{
1486 Id: "id456",
1487 Topic: "me",
1488 },
1489 AsUser: uid.UserId(),
1490 sess: s,
1491 }
1492
1493 // Deactivate topic.
1494 helper.topic.markDeleted()
1495
1496 helper.topic.registerSession(join)
1497 helper.finish()
1498
1499 // Check for errors from testHubLoop
1500 if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError {
1501 t.Fatal(errorMsgs[0].Ctrl.Text)
1502 }
1503
1504 if len(s.subs) != 0 {
1505 t.Errorf("Session subscriptions: expected 0, found %d", len(s.subs))
1506 }
1507 online := helper.topic.perUser[uid].online
1508 if online != 0 {
1509 t.Errorf("Number of online sessions: expected 0, found %d", online)
1510 }
1511 // Session output.
1512 registerSessionVerifyOutputs(t, helper.results[0], []int{http.StatusServiceUnavailable})
1513 // Presence notifications.
1514 if len(helper.hubMessages) != 0 {
1515 t.Errorf("Hub isn't expected to receive any messages, received %d", len(helper.hubMessages))
1516 }
1517}
1518
1519func TestRegisterSessionUserSpecifiedInSetMessage(t *testing.T) {
1520 topicName := "grpTest"

Callers

nothing calls this directly

Calls 7

setUpMethod · 0.95
tearDownMethod · 0.95
finishMethod · 0.95
UserIdMethod · 0.80
markDeletedMethod · 0.80
registerSessionMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…