diff --git a/internal/postgres/user_test.go b/internal/postgres/user_test.go index a57eb10..006dc9c 100644 --- a/internal/postgres/user_test.go +++ b/internal/postgres/user_test.go @@ -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() diff --git a/pkg/database/postgres_test.go b/pkg/database/postgres_test.go index b29dba0..9de1078 100644 --- a/pkg/database/postgres_test.go +++ b/pkg/database/postgres_test.go @@ -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 +}