From e615aab2329dc1e22a9e9edd3ff1282e45d01f55 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 13 Feb 2015 10:57:35 +0800 Subject: [PATCH] Rename anonymous_struct_test.go to embedded_struct_test.go --- ...ymous_struct_test.go => embedded_struct_test.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) rename anonymous_struct_test.go => embedded_struct_test.go (75%) diff --git a/anonymous_struct_test.go b/embedded_struct_test.go similarity index 75% rename from anonymous_struct_test.go rename to embedded_struct_test.go index fe571869..de1781dd 100644 --- a/anonymous_struct_test.go +++ b/embedded_struct_test.go @@ -5,7 +5,7 @@ import "testing" type BasePost struct { Id int64 Title string - Url string + URL string } type HNPost struct { @@ -24,19 +24,15 @@ func TestSaveAndQueryEmbeddedStruct(t *testing.T) { var news HNPost if err := DB.First(&news, "title = ?", "hn_news").Error; err != nil { t.Errorf("no error should happen when query with embedded struct, but got %v", err) - } else { - if news.BasePost.Title != "hn_news" { - t.Errorf("embedded struct's value should be scanned correctly") - } + } else if news.Title != "hn_news" { + t.Errorf("embedded struct's value should be scanned correctly") } DB.Save(&EngadgetPost{BasePost: BasePost{Title: "engadget_news"}}) var egNews EngadgetPost if err := DB.First(&egNews, "title = ?", "engadget_news").Error; err != nil { t.Errorf("no error should happen when query with embedded struct, but got %v", err) - } else { - if egNews.BasePost.Title != "engadget_news" { - t.Errorf("embedded struct's value should be scanned correctly") - } + } else if egNews.BasePost.Title != "engadget_news" { + t.Errorf("embedded struct's value should be scanned correctly") } }