Add has one panic test
This commit is contained in:
parent
6e680b39ed
commit
5fd2fe7462
@ -255,3 +255,15 @@ func TestPolymorphicHasOneAssociationForSlice(t *testing.T) {
|
||||
DB.Model(&pets).Association("Toy").Clear()
|
||||
AssertAssociationCount(t, pets, "Toy", 0, "After Clear")
|
||||
}
|
||||
|
||||
func TestHasOneAssociationReplaceWithNonValidValue(t *testing.T) {
|
||||
user := User{Name: "jinzhu", Account: Account{Number: "1"}}
|
||||
|
||||
if err := DB.Create(&user).Error; err != nil {
|
||||
t.Fatalf("errors happened when create: %v", err)
|
||||
}
|
||||
|
||||
if err := DB.Model(&user).Association("Languages").Replace(Account{Number: "2"}); err == nil {
|
||||
t.Error("expected association error to be not nil")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user