Merge 88625e8e3eab274de0cee518a0e25d15c996a0e0 into 9acaa33324bbcc78239a1c913d4f1292c12177b9

This commit is contained in:
Yuta Hayashibe 2017-05-05 07:16:30 +00:00 committed by GitHub
commit 9916bf0b55

View File

@ -599,6 +599,11 @@ func TestFindOrCreate(t *testing.T) {
t.Errorf("user should be created with search value and assigned attrs") t.Errorf("user should be created with search value and assigned attrs")
} }
DB.Where(&User{Name: "find or create 4"}).Assign(User{Age: 0}).FirstOrCreate(&user4)
if user4.Name != "find or create 4" || user4.Id == 0 || user4.Age != 0 {
t.Errorf("user should be created with search value and assigned attrs")
}
DB.Where(&User{Name: "find or create"}).Attrs("age", 44).FirstOrInit(&user5) DB.Where(&User{Name: "find or create"}).Attrs("age", 44).FirstOrInit(&user5)
if user5.Name != "find or create" || user5.Id == 0 || user5.Age != 33 { if user5.Name != "find or create" || user5.Id == 0 || user5.Age != 33 {
t.Errorf("user should be found and not initialized by Attrs") t.Errorf("user should be found and not initialized by Attrs")