MCPcopy
hub / github.com/go-gorm/gorm / doCheckPet

Function doCheckPet

tests/helper_test.go:92–110  ·  view source on GitHub ↗
(t *testing.T, pet Pet, expect Pet, unscoped bool)

Source from the content-addressed store, hash-verified

90}
91
92func doCheckPet(t *testing.T, pet Pet, expect Pet, unscoped bool) {
93 if pet.ID != 0 {
94 var newPet Pet
95 if err := db(unscoped).Where("id = ?", pet.ID).First(&newPet).Error; err != nil {
96 t.Fatalf("errors happened when query: %v", err)
97 } else {
98 AssertObjEqual(t, newPet, pet, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "UserID", "Name")
99 AssertObjEqual(t, newPet, expect, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "UserID", "Name")
100 }
101 }
102
103 AssertObjEqual(t, pet, expect, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "UserID", "Name")
104
105 AssertObjEqual(t, pet.Toy, expect.Toy, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "Name", "OwnerID", "OwnerType")
106
107 if expect.Toy.Name != "" && expect.Toy.OwnerType != "pets" {
108 t.Errorf("toys's OwnerType, expect: %v, got %v", "pets", expect.Toy.OwnerType)
109 }
110}
111
112func CheckUserUnscoped(t *testing.T, user User, expect User) {
113 doCheckUser(t, user, expect, true)

Callers 3

CheckPetUnscopedFunction · 0.85
CheckPetFunction · 0.85
doCheckUserFunction · 0.85

Calls 4

dbFunction · 0.85
AssertObjEqualFunction · 0.85
FirstMethod · 0.65
WhereMethod · 0.65

Tested by

no test coverage detected