Skip to content

Commit c1d6c20

Browse files
smolaRoberto Santalla
authored and
Roberto Santalla
committed
test: fix PostgreSQL with non-UTC timezone, fixes #203 (#273)
When we use kallax against a PostgreSQL with a timezone other than UTC, times will be returned using that timezone. So, on tests, we just convert returned times to UTC before comparison. Signed-off-by: Santiago M. Mola <[email protected]>
1 parent 0ff8479 commit c1d6c20

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: types/types_test.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ func TestNullable(t *testing.T) {
139139
PtrDuration *time.Duration
140140
)
141141
tim := time.Now().UTC()
142-
tim = time.Date(tim.Year(), tim.Month(), tim.Day(), tim.Hour(), tim.Minute(), tim.Second(), 0, tim.Location())
142+
tim = time.Date(tim.Year(), tim.Month(), tim.Day(), tim.Hour(),
143+
tim.Minute(), tim.Second(), 0, tim.Location())
143144
s := require.New(t)
144145
url, err := url.Parse("http://foo.me")
145146
s.NoError(err)
@@ -431,7 +432,14 @@ func TestNullable(t *testing.T) {
431432
if c.isPtr {
432433
elem = elem.Elem()
433434
}
434-
s.Equal(c.nonNullInput, elem.Interface(), c.name)
435+
436+
result := elem.Interface()
437+
switch v := result.(type) {
438+
case time.Time:
439+
result = v.UTC()
440+
}
441+
442+
s.Equal(c.nonNullInput, result, c.name)
435443

436444
_, err = db.Exec("DROP TABLE foo")
437445
s.Nil(err, c.name)

0 commit comments

Comments
 (0)