From 675283f0fe5ed665c1ccb9c18fb689976f69afc6 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Tue, 12 Jan 2016 15:47:47 +0800 Subject: [PATCH] Testing UpdateDecodeVirtualAttributes --- update_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/update_test.go b/update_test.go index 75877488..d483705c 100644 --- a/update_test.go +++ b/update_test.go @@ -419,3 +419,18 @@ func TestUpdateColumnsSkipsAssociations(t *testing.T) { t.Errorf("Expected user's BillingAddress.Address1=%s to remain unchanged after UpdateColumns invocation, but BillingAddress.Address1=%s", address1, freshUser.BillingAddress.Address1) } } + +func TestUpdateDecodeVirtualAttributes(t *testing.T) { + var user = User{ + Name: "jinzhu", + IgnoreMe: 88, + } + + DB.Save(&user) + + DB.Model(&user).Updates(User{Name: "jinzhu2", IgnoreMe: 100}) + + if user.IgnoreMe != 100 { + t.Errorf("should decode virtual attributes to struct, so it could be used in callbacks") + } +}