From dc2f27401eb44bb575423b467709f8f529dd9002 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sat, 15 Mar 2014 10:41:12 +0800 Subject: [PATCH] Test search data using time with zone --- main_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main_test.go b/main_test.go index 87fa9b21..1df4558a 100644 --- a/main_test.go +++ b/main_test.go @@ -1721,7 +1721,7 @@ func TestTimeWithZone(t *testing.T) { t.Errorf("User's deleted at should be zero") } - var findUser User + var findUser, findUser2, findUser3 User db.First(&findUser, "name = ?", name) if findUser.Birthday.UTC().Format(format) != "2013-02-18 17:51:49 +0000" { t.Errorf("User's birthday should not be changed after find") @@ -1730,6 +1730,14 @@ func TestTimeWithZone(t *testing.T) { if findUser.DeletedAt.UTC().Format(format) != "0001-01-01 00:00:00 +0000" { t.Errorf("User's deleted at should be zero") } + + if db.Where("birthday >= ?", vtime.Add(-time.Minute)).First(&findUser2).RecordNotFound() { + t.Errorf("User should be found") + } + + if !db.Where("birthday >= ?", vtime.Add(time.Minute)).First(&findUser3).RecordNotFound() { + t.Errorf("User should not be found") + } } }