From 485dfe2888e4576c3d36b412698d637f605c4f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferdinand=20M=C3=BCtsch?= Date: Sun, 28 Nov 2021 12:40:46 +0100 Subject: [PATCH] fix: user time zone test (fix #275) [ci skip] --- models/user_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/models/user_test.go b/models/user_test.go index 323aed1..305d43f 100644 --- a/models/user_test.go +++ b/models/user_test.go @@ -9,11 +9,12 @@ import ( func TestUser_TZ(t *testing.T) { sut1, sut2 := &User{Location: ""}, &User{Location: "America/Los_Angeles"} pst, _ := time.LoadLocation("America/Los_Angeles") - _, offset := time.Now().Zone() + _, offset1 := time.Now().Zone() + _, offset2 := time.Now().In(pst).Zone() assert.Equal(t, time.Local, sut1.TZ()) assert.Equal(t, pst, sut2.TZ()) - assert.InDelta(t, time.Duration(offset*int(time.Second)), sut1.TZOffset(), float64(1*time.Second)) - assert.InDelta(t, time.Duration(-7*int(time.Hour)), sut2.TZOffset(), float64(1*time.Second)) + assert.InDelta(t, time.Duration(offset1*int(time.Second)), sut1.TZOffset(), float64(1*time.Second)) + assert.InDelta(t, time.Duration(offset2*int(time.Second)), sut2.TZOffset(), float64(1*time.Second)) }