Fixed Pagination & modles #14
@ -573,13 +573,30 @@ func TestGetUserFavoriteNodeWithPagination(t *testing.T) {
|
||||
t.Errorf("GetAllUserFavoritesWithPagination() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
if !checkFavoritePosts(got, tt.want) {
|
||||
t.Errorf("GetAllUserFavoritesWithPagination() got = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func checkFavoritePosts(got *models.FavoriteList, want *models.FavoriteList) bool {
|
||||
if got == nil && want == nil {
|
||||
return true
|
||||
} else if got == nil || want == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
for i, post := range got.Posts {
|
||||
if post.ID == want.Posts[i].ID {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func TestGetUserFavoritesCount(t *testing.T) {
|
||||
// Setup trow away container
|
||||
ctx := context.Background()
|
||||
|
@ -1556,7 +1556,7 @@ func Test_postgresqlConnection_GetUserFavoriteWithPagination(t *testing.T) {
|
||||
t.Errorf("GetAllUserFavoritesWithPagination() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
if !checkFavoritePosts(got, tt.want) {
|
||||
t.Errorf("GetAllUserFavoritesWithPagination() got = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
@ -3654,3 +3654,20 @@ func Test_postgresqlConnection_CreatePostInBatch(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func checkFavoritePosts(got *models.FavoriteList, want *models.FavoriteList) bool {
|
||||
if got == nil && want == nil {
|
||||
return true
|
||||
} else if got == nil || want == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
for i, post := range got.Posts {
|
||||
if post.ID == want.Posts[i].ID {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
Reference in New Issue
Block a user