From 96ade8c6196ac5c450e54ba3e196b707828e8005 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sat, 23 Nov 2013 22:06:52 +0800 Subject: [PATCH] NewRecord should also works with struct pointer --- gorm_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gorm_test.go b/gorm_test.go index 472df1f2..816b47cb 100644 --- a/gorm_test.go +++ b/gorm_test.go @@ -166,6 +166,10 @@ func TestCreateAndUpdate(t *testing.T) { t.Error("User should be new record") } + if !db.NewRecord(&user) { + t.Error("User should be new record") + } + db.Save(&user) if user.Id == 0 { t.Errorf("Should have ID after create") @@ -175,6 +179,10 @@ func TestCreateAndUpdate(t *testing.T) { t.Error("User should not new record after save") } + if db.NewRecord(&user) { + t.Error("User should not new record after save") + } + var u User db.First(&u, user.Id) if !reflect.DeepEqual(u.PasswordHash, []byte{'f', 'a', 'k', '4'}) {