@@ -12,7 +12,6 @@ import (
1212 "time"
1313
1414 "github.com/SlotifyApp/slotify-backend/api"
15- "github.com/SlotifyApp/slotify-backend/database"
1615 "github.com/SlotifyApp/slotify-backend/mocks"
1716 "github.com/SlotifyApp/slotify-backend/testutil"
1817 "github.com/google/uuid"
@@ -172,14 +171,11 @@ func TestAPISlotifyGroupsSlotifyGroupIDInvites(t *testing.T) {
172171 )
173172 require .Equal (t , http .StatusOK , rr .Result ().StatusCode )
174173
175- var resp struct {
176- Invites []database.ListInvitesByGroupRow `json:"invites"`
177- NextPageToken int `json:"nextPageToken,omitempty"`
178- }
174+ var resp api.InvitesGroupsAndPagination
179175 err = json .NewDecoder (rr .Result ().Body ).Decode (& resp )
180176 require .NoError (t , err )
181177 require .Empty (t , resp .Invites , "should return no invites" )
182- require .Equal (t , 0 , resp .NextPageToken , "nextPageToken should be 0 when no invites" )
178+ require .Equal (t , uint32 ( 0 ) , resp .NextPageToken , "nextPageToken should be 0 when no invites" )
183179 })
184180
185181 t .Run ("less than limit invites" , func (t * testing.T ) {
@@ -206,14 +202,12 @@ func TestAPISlotifyGroupsSlotifyGroupIDInvites(t *testing.T) {
206202 )
207203 require .Equal (t , http .StatusOK , rr .Result ().StatusCode )
208204
209- var resp struct {
210- Invites []database.ListInvitesByGroupRow `json:"invites"`
211- NextPageToken int `json:"nextPageToken,omitempty"`
212- }
205+ var resp api.InvitesGroupsAndPagination
213206 err = json .NewDecoder (rr .Result ().Body ).Decode (& resp )
214207 require .NoError (t , err )
215208 require .Len (t , resp .Invites , 5 , "should return 5 invites" )
216- require .Equal (t , 0 , resp .NextPageToken , "nextPageToken should be 0 when invites are less than limit" )
209+ require .Equal (t , uint32 (0 ), resp .NextPageToken ,
210+ "nextPageToken should be 0 when invites are less than limit" )
217211 })
218212
219213 t .Run ("pagination" , func (t * testing.T ) {
@@ -241,10 +235,7 @@ func TestAPISlotifyGroupsSlotifyGroupIDInvites(t *testing.T) {
241235 )
242236 require .Equal (t , http .StatusOK , rr .Result ().StatusCode )
243237
244- var resp struct {
245- Invites []database.ListInvitesByGroupRow `json:"invites"`
246- NextPageToken int `json:"nextPageToken,omitempty"`
247- }
238+ var resp api.InvitesGroupsAndPagination
248239 err = json .NewDecoder (rr .Result ().Body ).Decode (& resp )
249240 require .NoError (t , err )
250241 require .Len (t , resp .Invites , 10 , "first page should return 10 invites" )
@@ -266,22 +257,18 @@ func TestAPISlotifyGroupsSlotifyGroupIDInvites(t *testing.T) {
266257 req2 .Header .Set (api .ReqHeader , uuid .NewString ())
267258 req2 = req2 .WithContext (context .WithValue (req2 .Context (), api.UserIDCtxKey {}, testUser .Id ))
268259
269- nextToken := uint32 (resp .NextPageToken )
270260 server .GetAPISlotifyGroupsSlotifyGroupIDInvites (
271261 rr2 ,
272262 req2 ,
273263 testGroup .Id ,
274264 api.GetAPISlotifyGroupsSlotifyGroupIDInvitesParams {
275- PageToken : & nextToken ,
265+ PageToken : & resp . NextPageToken ,
276266 Limit : testutil .PageLimit ,
277267 },
278268 )
279269 require .Equal (t , http .StatusOK , rr2 .Result ().StatusCode )
280270
281- var resp2 struct {
282- Invites []database.ListInvitesByGroupRow `json:"invites"`
283- NextPageToken int `json:"nextPageToken,omitempty"`
284- }
271+ var resp2 api.InvitesGroupsAndPagination
285272 err = json .NewDecoder (rr2 .Result ().Body ).Decode (& resp2 )
286273 require .NoError (t , err )
287274 require .Len (t , resp2 .Invites , 1 , "second page should return the remaining invite" )
0 commit comments