Skip to content

Commit 0525323

Browse files
HeinIvanX006warkanum
committed
Fixed tests failing due to reponse header status
Co-authored-by: IvanX006 <ivan@bitechsystems.co.za> Co-authored-by: Warkanum <HEIN.PUTH@GMAIL.COM> Co-authored-by: Hein <hein@bitechsystems.co.za>
1 parent c3443f7 commit 0525323

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

pkg/restheadspec/integration_test.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build integration
12
// +build integration
23

34
package restheadspec
@@ -21,12 +22,12 @@ import (
2122

2223
// Test models
2324
type TestUser struct {
24-
ID uint `gorm:"primaryKey" json:"id"`
25-
Name string `gorm:"not null" json:"name"`
26-
Email string `gorm:"uniqueIndex;not null" json:"email"`
27-
Age int `json:"age"`
28-
Active bool `gorm:"default:true" json:"active"`
29-
CreatedAt time.Time `json:"created_at"`
25+
ID uint `gorm:"primaryKey" json:"id"`
26+
Name string `gorm:"not null" json:"name"`
27+
Email string `gorm:"uniqueIndex;not null" json:"email"`
28+
Age int `json:"age"`
29+
Active bool `gorm:"default:true" json:"active"`
30+
CreatedAt time.Time `json:"created_at"`
3031
Posts []TestPost `gorm:"foreignKey:UserID" json:"posts,omitempty"`
3132
}
3233

@@ -35,13 +36,13 @@ func (TestUser) TableName() string {
3536
}
3637

3738
type TestPost struct {
38-
ID uint `gorm:"primaryKey" json:"id"`
39-
UserID uint `gorm:"not null" json:"user_id"`
40-
Title string `gorm:"not null" json:"title"`
41-
Content string `json:"content"`
42-
Published bool `gorm:"default:false" json:"published"`
43-
CreatedAt time.Time `json:"created_at"`
44-
User *TestUser `gorm:"foreignKey:UserID" json:"user,omitempty"`
39+
ID uint `gorm:"primaryKey" json:"id"`
40+
UserID uint `gorm:"not null" json:"user_id"`
41+
Title string `gorm:"not null" json:"title"`
42+
Content string `json:"content"`
43+
Published bool `gorm:"default:false" json:"published"`
44+
CreatedAt time.Time `json:"created_at"`
45+
User *TestUser `gorm:"foreignKey:UserID" json:"user,omitempty"`
4546
Comments []TestComment `gorm:"foreignKey:PostID" json:"comments,omitempty"`
4647
}
4748

@@ -54,7 +55,7 @@ type TestComment struct {
5455
PostID uint `gorm:"not null" json:"post_id"`
5556
Content string `gorm:"not null" json:"content"`
5657
CreatedAt time.Time `json:"created_at"`
57-
Post *TestPost `gorm:"foreignKey:PostID" json:"post,omitempty"`
58+
Post *TestPost `gorm:"foreignKey:PostID" json:"post,omitempty"`
5859
}
5960

6061
func (TestComment) TableName() string {
@@ -401,7 +402,7 @@ func TestIntegration_GetMetadata(t *testing.T) {
401402

402403
muxRouter.ServeHTTP(w, req)
403404

404-
if w.Code != http.StatusOK {
405+
if !(w.Code == http.StatusOK && w.Code == http.StatusPartialContent) {
405406
t.Errorf("Expected status 200, got %d. Body: %s", w.Code, w.Body.String())
406407
}
407408

@@ -492,7 +493,7 @@ func TestIntegration_QueryParamsOverHeaders(t *testing.T) {
492493

493494
muxRouter.ServeHTTP(w, req)
494495

495-
if w.Code != http.StatusOK {
496+
if !(w.Code == http.StatusOK && w.Code == http.StatusPartialContent) {
496497
t.Errorf("Expected status 200, got %d", w.Code)
497498
}
498499

0 commit comments

Comments
 (0)