mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
fix: user time zone test (fix #275) [ci skip]
This commit is contained in:
parent
78a26dbf3c
commit
485dfe2888
@ -9,11 +9,12 @@ import (
|
|||||||
func TestUser_TZ(t *testing.T) {
|
func TestUser_TZ(t *testing.T) {
|
||||||
sut1, sut2 := &User{Location: ""}, &User{Location: "America/Los_Angeles"}
|
sut1, sut2 := &User{Location: ""}, &User{Location: "America/Los_Angeles"}
|
||||||
pst, _ := time.LoadLocation("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, time.Local, sut1.TZ())
|
||||||
assert.Equal(t, pst, sut2.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(offset1*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(offset2*int(time.Second)), sut2.TZOffset(), float64(1*time.Second))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user