(t *testing.T)
| 2511 | } |
| 2512 | |
| 2513 | func 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. |
| 2570 | type supersetOf struct{ subset map[string]string } |
nothing calls this directly
no test coverage detected
searching dependent graphs…