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

Function TestHandleMetaGet

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

Source from the content-addressed store, hash-verified

2511}
2512
2513func TestHandleMetaGet(t *testing.T) {
2514 topicName := "usrMe"
2515 numUsers := 1
2516 helper := TopicTestHelper{}
2517 helper.setUp(t, numUsers, types.TopicCatMe, topicName, true)
2518 defer helper.tearDown()
2519
2520 uid := helper.uids[0]
2521 helper.mm.EXPECT().GetAll(topicName, uid, gomock.Any()).Return([]types.Message{}, nil)
2522 helper.mm.EXPECT().GetDeleted(topicName, uid, gomock.Any()).Return([]types.Range{}, 0, nil)
2523 helper.uu.EXPECT().GetTopics(uid, gomock.Any()).Return([]types.Subscription{}, nil)
2524
2525 meta := &ClientComMessage{
2526 Get: &MsgClientGet{
2527 Id: "id456",
2528 Topic: topicName,
2529 MsgGetQuery: MsgGetQuery{
2530 What: "desc sub data del",
2531 Desc: &MsgGetOpts{},
2532 Sub: &MsgGetOpts{},
2533 Data: &MsgGetOpts{},
2534 Del: &MsgGetOpts{},
2535 },
2536 },
2537 AsUser: uid.UserId(),
2538 MetaWhat: constMsgMetaDesc | constMsgMetaSub | constMsgMetaData | constMsgMetaDel,
2539 sess: helper.sessions[0],
2540 }
2541 helper.topic.handleMeta(meta)
2542 helper.finish()
2543
2544 // Check for errors from testHubLoop
2545 if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError {
2546 t.Fatal(errorMsgs[0].Ctrl.Text)
2547 }
2548
2549 r := helper.results[0]
2550 if len(r.messages) != 4 {
2551 t.Errorf("responses received: expected 4, received %d", len(r.messages))
2552 }
2553 for _, msg := range r.messages {
2554 m := msg.(*ServerComMessage)
2555 if m.Meta != nil {
2556 if m.Meta.Desc == nil {
2557 t.Error("Meta.Desc expected to be specified.")
2558 }
2559 } else if m.Ctrl == nil {
2560 t.Error("Expected only meta or ctrl messages.")
2561 }
2562 }
2563 // Presence notifications.
2564 if len(helper.hubMessages) != 0 {
2565 t.Errorf("Hub messages recipients: expected 0, received %d", len(helper.hubMessages))
2566 }
2567}
2568
2569// Matches a subset in a superset.
2570type supersetOf struct{ subset map[string]string }

Callers

nothing calls this directly

Calls 10

setUpMethod · 0.95
tearDownMethod · 0.95
finishMethod · 0.95
UserIdMethod · 0.80
handleMetaMethod · 0.80
ErrorMethod · 0.80
GetAllMethod · 0.65
GetDeletedMethod · 0.65
GetTopicsMethod · 0.65
EXPECTMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…