NewRecord should also works with struct pointer

This commit is contained in:
Jinzhu 2013-11-23 22:06:52 +08:00
parent 660ee1ed73
commit 96ade8c619
1 changed files with 8 additions and 0 deletions

View File

@ -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'}) {