(t *testing.T)
| 3082 | } |
| 3083 | |
| 3084 | func TestUnregisterSessionWithPendingCall(t *testing.T) { |
| 3085 | numUsers := 2 |
| 3086 | helper := TopicTestHelper{} |
| 3087 | helper.setUp(t, numUsers, types.TopicCatP2P, "p2p-test", true) |
| 3088 | defer helper.tearDown() |
| 3089 | |
| 3090 | uid := helper.uids[0] |
| 3091 | s := helper.sessions[0] |
| 3092 | r := helper.results[0] |
| 3093 | |
| 3094 | // Set up a pending call matching the actual videoCall structure |
| 3095 | helper.topic.currentCall = &videoCall{ |
| 3096 | seq: 123, |
| 3097 | parties: make(map[string]callPartyData), |
| 3098 | } |
| 3099 | helper.topic.currentCall.parties[s.sid] = callPartyData{ |
| 3100 | uid: uid, |
| 3101 | isOriginator: true, |
| 3102 | sess: s, |
| 3103 | } |
| 3104 | helper.mm.EXPECT().Save(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, true) |
| 3105 | |
| 3106 | leave := &ClientComMessage{ |
| 3107 | Leave: &MsgClientLeave{ |
| 3108 | Id: "id456", |
| 3109 | Topic: "p2p-test", |
| 3110 | }, |
| 3111 | AsUser: uid.UserId(), |
| 3112 | sess: s, |
| 3113 | init: true, |
| 3114 | } |
| 3115 | |
| 3116 | helper.topic.unregisterSession(leave) |
| 3117 | helper.finish() |
| 3118 | |
| 3119 | // Check for errors from testHubLoop |
| 3120 | if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError { |
| 3121 | t.Fatal(errorMsgs[0].Ctrl.Text) |
| 3122 | } |
| 3123 | |
| 3124 | // Verify session was unregistered |
| 3125 | if len(helper.topic.sessions) != 1 { |
| 3126 | t.Errorf("Attached sessions: expected 1, found %d", len(helper.topic.sessions)) |
| 3127 | } |
| 3128 | if len(s.subs) != 0 { |
| 3129 | t.Errorf("Session subscriptions: expected 0, found %d", len(s.subs)) |
| 3130 | } |
| 3131 | |
| 3132 | // Verify call party was removed (if the implementation handles this) |
| 3133 | if helper.topic.currentCall != nil && helper.topic.currentCall.parties != nil { |
| 3134 | if _, exists := helper.topic.currentCall.parties[s.sid]; exists { |
| 3135 | t.Error("Call party should have been removed when session unregistered") |
| 3136 | } |
| 3137 | } |
| 3138 | |
| 3139 | if len(r.messages) != 3 { |
| 3140 | t.Fatalf("`responses` expected to contain 3 elements, found %d", len(r.messages)) |
| 3141 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…