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

Function TestHasOneAssociationWithSelect

tests/associations_has_one_test.go:86–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

84}
85
86func TestHasOneAssociationWithSelect(t *testing.T) {
87 user := *GetUser("hasone", Config{Account: true})
88
89 DB.Omit("Account.Number").Create(&user)
90
91 AssertAssociationCount(t, user, "Account", 1, "")
92
93 var account Account
94 DB.Model(&user).Association("Account").Find(&account)
95 if account.Number != "" {
96 t.Errorf("account's number should not be saved")
97 }
98}
99
100func TestHasOneAssociationForSlice(t *testing.T) {
101 users := []User{

Callers

nothing calls this directly

Calls 7

GetUserFunction · 0.85
AssertAssociationCountFunction · 0.85
ModelMethod · 0.80
CreateMethod · 0.65
OmitMethod · 0.65
FindMethod · 0.65
AssociationMethod · 0.45

Tested by

no test coverage detected