From d8f7d4a24393e9ff62c4686120c6b1b47c78d222 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sun, 5 Jan 2014 09:37:15 +0800 Subject: [PATCH] update tests --- gorm_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gorm_test.go b/gorm_test.go index aa7eae8d..21871db7 100644 --- a/gorm_test.go +++ b/gorm_test.go @@ -1471,34 +1471,34 @@ func TestSqlNullValue(t *testing.T) { } func TestTransaction(t *testing.T) { - d := db.Begin() + tx := db.Begin() u := User{Name: "transcation"} - if err := d.Save(&u).Error; err != nil { + if err := tx.Save(&u).Error; err != nil { t.Errorf("No error should raise, but got", err) } - if err := d.First(&User{}, "name = ?", "transcation").Error; err != nil { + if err := tx.First(&User{}, "name = ?", "transcation").Error; err != nil { t.Errorf("Should find saved record, but got", err) } - d.Rollback() + tx.Rollback() - if err := d.First(&User{}, "name = ?", "transcation").Error; err == nil { + if err := tx.First(&User{}, "name = ?", "transcation").Error; err == nil { t.Errorf("Should not find record after rollback") } - d2 := db.Begin() + tx2 := db.Begin() u2 := User{Name: "transcation-2"} - if err := d2.Save(&u2).Error; err != nil { + if err := tx2.Save(&u2).Error; err != nil { t.Errorf("No error should raise, but got", err) } - d2.Update("age", 90) + tx2.Update("age", 90) - if err := d2.First(&User{}, "name = ?", "transcation-2").Error; err != nil { + if err := tx2.First(&User{}, "name = ?", "transcation-2").Error; err != nil { t.Errorf("Should find saved record, but got", err) } - d2.Commit() + tx2.Commit() if err := db.First(&User{}, "name = ?", "transcation-2").Error; err != nil { t.Errorf("Should be able to find committed record")