(t *testing.T)
| 2380 | } |
| 2381 | |
| 2382 | func TestUnregisterSessionOwnerCannotUnsubscribe(t *testing.T) { |
| 2383 | topicName := "grpTest" |
| 2384 | numUsers := 3 |
| 2385 | helper := TopicTestHelper{} |
| 2386 | helper.setUp(t, numUsers, types.TopicCatGrp, topicName, true) |
| 2387 | defer helper.tearDown() |
| 2388 | |
| 2389 | uid := helper.uids[0] |
| 2390 | s := helper.sessions[0] |
| 2391 | r := helper.results[0] |
| 2392 | |
| 2393 | leave := &ClientComMessage{ |
| 2394 | Leave: &MsgClientLeave{ |
| 2395 | Id: "id456", |
| 2396 | Topic: topicName, |
| 2397 | Unsub: true, |
| 2398 | }, |
| 2399 | AsUser: uid.UserId(), |
| 2400 | sess: s, |
| 2401 | init: true, |
| 2402 | } |
| 2403 | |
| 2404 | helper.topic.unregisterSession(leave) |
| 2405 | helper.finish() |
| 2406 | |
| 2407 | // Check for errors from testHubLoop |
| 2408 | if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError { |
| 2409 | t.Fatal(errorMsgs[0].Ctrl.Text) |
| 2410 | } |
| 2411 | |
| 2412 | if len(helper.topic.sessions) != 3 { |
| 2413 | t.Errorf("Attached sessions: expected 3, found %d", len(helper.topic.sessions)) |
| 2414 | } |
| 2415 | if len(s.subs) != 0 { |
| 2416 | t.Errorf("Session subscriptions: expected 0, found %d", len(helper.sessions[0].subs)) |
| 2417 | } |
| 2418 | if online := helper.topic.perUser[uid].online; online != 1 { |
| 2419 | t.Errorf("Number of online sessions after failed unsubscribing: expected 1, found %d.", online) |
| 2420 | } |
| 2421 | // Session output. |
| 2422 | registerSessionVerifyOutputs(t, r, []int{http.StatusForbidden}) |
| 2423 | // Presence notifications. |
| 2424 | if len(helper.hubMessages) != 0 { |
| 2425 | t.Errorf("Hub messages recipients: expected 0, received %d", len(helper.hubMessages)) |
| 2426 | } |
| 2427 | } |
| 2428 | |
| 2429 | func TestUnregisterSessionUnsubDeleteCallFails(t *testing.T) { |
| 2430 | topicName := "grpTest" |
nothing calls this directly
no test coverage detected
searching dependent graphs…