Skip to content

Commit

Permalink
test: fix PostgreSQL with non-UTC timezone, fixes #203 (#273)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
smola authored and Roberto Santalla committed Jun 18, 2018
1 parent 0ff8479 commit c1d6c20
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ func TestNullable(t *testing.T) {
PtrDuration *time.Duration
)
tim := time.Now().UTC()
tim = time.Date(tim.Year(), tim.Month(), tim.Day(), tim.Hour(), tim.Minute(), tim.Second(), 0, tim.Location())
tim = time.Date(tim.Year(), tim.Month(), tim.Day(), tim.Hour(),
tim.Minute(), tim.Second(), 0, tim.Location())
s := require.New(t)
url, err := url.Parse("http://foo.me")
s.NoError(err)
Expand Down Expand Up @@ -431,7 +432,14 @@ func TestNullable(t *testing.T) {
if c.isPtr {
elem = elem.Elem()
}
s.Equal(c.nonNullInput, elem.Interface(), c.name)

result := elem.Interface()
switch v := result.(type) {
case time.Time:
result = v.UTC()
}

s.Equal(c.nonNullInput, result, c.name)

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

0 comments on commit c1d6c20

Please sign in to comment.