Fix meeting list and media search issues
This commit is contained in:
@@ -263,6 +263,9 @@ type testOrganizationStore struct {
|
||||
|
||||
type testMeetingsStore struct {
|
||||
meeting *types.Meeting
|
||||
list []types.Meeting
|
||||
listCursor string
|
||||
listLimit int
|
||||
attendeeIDs []types.Uid
|
||||
created *types.Meeting
|
||||
response string
|
||||
@@ -604,6 +607,12 @@ func (s *testMeetingsStore) Create(_ types.TenantID, uid types.Uid, meeting *typ
|
||||
return meeting, nil
|
||||
}
|
||||
|
||||
func (s *testMeetingsStore) List(_ types.TenantID, _ types.Uid, cursor string, limit int) ([]types.Meeting, string, error) {
|
||||
s.listCursor = cursor
|
||||
s.listLimit = limit
|
||||
return s.list, "next-1", nil
|
||||
}
|
||||
|
||||
func (s *testMeetingsStore) Get(_ types.TenantID, _ types.Uid, _ string) (*types.Meeting, error) {
|
||||
return s.meeting, nil
|
||||
}
|
||||
@@ -2355,6 +2364,49 @@ func TestServeIMMeetingsCreate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestServeIMMeetingsList(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
viewer := types.Uid(42)
|
||||
expectIMBearer(t, ctrl, "token-1", 7, viewer)
|
||||
oldMeetings := store.Meetings
|
||||
now := time.Now().UTC().Round(time.Millisecond)
|
||||
meetings := &testMeetingsStore{list: []types.Meeting{{
|
||||
MeetingID: "mtg_test",
|
||||
OrganizerID: viewer,
|
||||
Title: "周会",
|
||||
StartAt: now.Add(time.Hour),
|
||||
EndAt: now.Add(2 * time.Hour),
|
||||
Location: "A101",
|
||||
State: types.MeetingStateScheduled,
|
||||
Version: 1,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
Participants: []types.MeetingParticipant{
|
||||
{MeetingID: "mtg_test", UserID: viewer, Response: types.MeetingResponseAccepted},
|
||||
},
|
||||
}}}
|
||||
store.Meetings = meetings
|
||||
defer func() { store.Meetings = oldMeetings }()
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/v1/im/meetings?limit=20&cursor=c1", nil)
|
||||
req.Header.Set("Authorization", "Bearer token-1")
|
||||
rec := httptest.NewRecorder()
|
||||
serveIMMeetings(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status: got %d, want %d; body=%s", rec.Code, http.StatusOK, rec.Body.String())
|
||||
}
|
||||
data := decodeIMHTTPResponse(t, rec).Data.(map[string]any)
|
||||
items := data["items"].([]any)
|
||||
if len(items) != 1 || meetings.listCursor != "c1" || meetings.listLimit != 20 {
|
||||
t.Fatalf("unexpected list response: data=%#v cursor=%q limit=%d", data, meetings.listCursor, meetings.listLimit)
|
||||
}
|
||||
if items[0].(map[string]any)["meeting_id"] != "mtg_test" || data["has_more"] != true {
|
||||
t.Fatalf("unexpected meeting payload: %#v", data)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServeIMMeetingMyResponse(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
Reference in New Issue
Block a user