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

Function TestHandleTopicTermination

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

Source from the content-addressed store, hash-verified

2831}
2832
2833func TestHandleTopicTermination(t *testing.T) {
2834 topicName := "usrMe"
2835 numUsers := 1
2836 helper := TopicTestHelper{}
2837 helper.setUp(t, numUsers, types.TopicCatMe, topicName /*attach=*/, true)
2838 defer helper.tearDown()
2839
2840 done := make(chan bool, 1)
2841 exit := &shutDown{
2842 reason: StopDeleted,
2843 done: done,
2844 }
2845 helper.topic.handleTopicTermination(exit)
2846 helper.finish()
2847
2848 // Check for errors from testHubLoop
2849 if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError {
2850 t.Fatal(errorMsgs[0].Ctrl.Text)
2851 }
2852
2853 if len(done) != 1 {
2854 t.Fatal("done callback isn't invoked.")
2855 }
2856 <-done
2857 for i, s := range helper.sessions {
2858 if len(s.detach) != 1 {
2859 t.Fatalf("Session %d: detach channel is empty.", i)
2860 }
2861 val := <-s.detach
2862 if val != topicName {
2863 t.Errorf("Session %d is expected to detach from topic '%s', found '%s'.", i, topicName, val)
2864 }
2865 }
2866 // Presence notifications.
2867 if len(helper.hubMessages) != 0 {
2868 t.Fatalf("Hub messages recipients: expected 0, received %d", len(helper.hubMessages))
2869 }
2870}
2871
2872func TestHandleBroadcastDataWithAttachments(t *testing.T) {
2873 numUsers := 2

Callers

nothing calls this directly

Calls 4

setUpMethod · 0.95
tearDownMethod · 0.95
finishMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…