MCPcopy Index your code
hub / github.com/tinode/chat / TestHandleSessionUpdateUserAgent

Function TestHandleSessionUpdateUserAgent

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

Source from the content-addressed store, hash-verified

2696}
2697
2698func TestHandleSessionUpdateUserAgent(t *testing.T) {
2699 topicName := "usrMe"
2700 numUsers := 1
2701 helper := TopicTestHelper{}
2702 helper.setUp(t, numUsers, types.TopicCatMe, topicName /*attach=*/, true)
2703 defer helper.tearDown()
2704
2705 uid := helper.uids[0]
2706 supd := &sessionUpdate{
2707 userAgent: "newUA",
2708 }
2709 uaAgent := "oldUA"
2710 timer := time.NewTimer(time.Hour)
2711 helper.topic.handleSessionUpdate(supd, &uaAgent, timer)
2712 helper.finish()
2713
2714 // Check for errors from testHubLoop
2715 if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError {
2716 t.Fatal(errorMsgs[0].Ctrl.Text)
2717 }
2718
2719 // online count stays 1.
2720 if online := helper.topic.perUser[uid].online; online != 1 {
2721 t.Errorf("online count for %s: expected 1, found %d", uid.UserId(), online)
2722 }
2723 if uaAgent != "newUA" {
2724 t.Errorf("User agent: expected 'newUA', found '%s'", uaAgent)
2725 }
2726 timer.Stop()
2727}
2728
2729func TestHandleUATimerEvent(t *testing.T) {
2730 topicName := "usrMe"

Callers

nothing calls this directly

Calls 6

setUpMethod · 0.95
tearDownMethod · 0.95
finishMethod · 0.95
handleSessionUpdateMethod · 0.80
UserIdMethod · 0.80
StopMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…