(t *testing.T)
| 2596 | } |
| 2597 | |
| 2598 | func TestHandleMetaSetDescMePublicPrivate(t *testing.T) { |
| 2599 | topicName := "usrMe" |
| 2600 | numUsers := 1 |
| 2601 | helper := TopicTestHelper{} |
| 2602 | helper.setUp(t, numUsers, types.TopicCatMe, topicName /*attach=*/, true) |
| 2603 | defer helper.tearDown() |
| 2604 | |
| 2605 | uid := helper.uids[0] |
| 2606 | gomock.InOrder( |
| 2607 | helper.uu.EXPECT().Update(uid, SupersetOf(map[string]string{"Public": "new public"})).Return(nil), |
| 2608 | helper.ss.EXPECT().Update(topicName, uid, map[string]any{"Private": "new private"}).Return(nil), |
| 2609 | ) |
| 2610 | |
| 2611 | meta := &ClientComMessage{ |
| 2612 | Set: &MsgClientSet{ |
| 2613 | Id: "id456", |
| 2614 | Topic: topicName, |
| 2615 | MsgSetQuery: MsgSetQuery{ |
| 2616 | Desc: &MsgSetDesc{ |
| 2617 | Public: "new public", |
| 2618 | Private: "new private", |
| 2619 | }, |
| 2620 | }, |
| 2621 | }, |
| 2622 | AsUser: uid.UserId(), |
| 2623 | MetaWhat: constMsgMetaDesc, |
| 2624 | sess: helper.sessions[0], |
| 2625 | } |
| 2626 | helper.topic.handleMeta(meta) |
| 2627 | helper.finish() |
| 2628 | |
| 2629 | // Check for errors from testHubLoop |
| 2630 | if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError { |
| 2631 | t.Fatal(errorMsgs[0].Ctrl.Text) |
| 2632 | } |
| 2633 | |
| 2634 | r := helper.results[0] |
| 2635 | if len(r.messages) != 1 { |
| 2636 | t.Fatalf("responses received: expected 1, received %d", len(r.messages)) |
| 2637 | } |
| 2638 | msg := r.messages[0].(*ServerComMessage) |
| 2639 | if msg == nil || msg.Ctrl == nil { |
| 2640 | t.Fatalf("Server message expected to have a ctrl submessage: %+v", msg) |
| 2641 | } |
| 2642 | if msg.Ctrl.Code != 200 { |
| 2643 | t.Errorf("Response code: expected 200, found %d", msg.Ctrl.Code) |
| 2644 | } |
| 2645 | // Presence notifications. |
| 2646 | if len(helper.hubMessages) != 1 { |
| 2647 | t.Fatalf("Hub messages recipients: expected 1, received %d", len(helper.hubMessages)) |
| 2648 | } |
| 2649 | // Make sure uid's sessions are notified. |
| 2650 | if userPres, ok := helper.hubMessages[uid.UserId()]; ok { |
| 2651 | if len(userPres) != 1 { |
| 2652 | t.Fatalf("User presence messages: expected 1, got %d", len(userPres)) |
| 2653 | } |
| 2654 | if userPres[0].SkipSid != helper.sessions[0].sid { |
| 2655 | t.Errorf("Pres notification SkipSid: %s expected vs %s found", helper.sessions[0].sid, userPres[0].SkipSid) |
nothing calls this directly
no test coverage detected
searching dependent graphs…