Skip to content

Commit

Permalink
Fixing TZ test and adding a pointer value comparator
Browse files Browse the repository at this point in the history
  • Loading branch information
safaci2000 committed Oct 7, 2024
1 parent 89483e1 commit 9ce34f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions internal/testutils/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"runtime"
"testing"
"time"
"unsafe"

"github.com/google/go-cmp/cmp"
)
Expand Down Expand Up @@ -277,6 +278,13 @@ func AssertDeepEqual(t *testing.T, actual, expected interface{}, option ...cmp.O
}
}

// PointerComparer allows for comparison of the value of a given pointer
var PointerComparer = cmp.Comparer(func(x, y func() string) bool {
px := *(*unsafe.Pointer)(unsafe.Pointer(&x))
py := *(*unsafe.Pointer)(unsafe.Pointer(&y))
return px == py
})

func assertQueryString(t *testing.T, actual, expected string) {
if !assert.Equal(t, actual, expected) {
printDiff(actual, expected)
Expand Down
4 changes: 2 additions & 2 deletions tests/postgres/sample_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,10 @@ ORDER BY employee.employee_id;
EmployeeID: 1,
FirstName: "Windy",
LastName: "Hays",
EmploymentDate: testutils.TimestampWithTimeZone("1999-01-08 04:05:06.1 +0100 CET", 1),
EmploymentDate: testutils.TimestampWithTimeZone("1999-01-08 03:05:06.1 +0000 UTC", 1),
ManagerID: nil,
PtoAccrual: ptr.Of("22:00:00"),
})
}, testutils.PointerComparer)

require.True(t, dest[0].Manager == nil)

Expand Down

0 comments on commit 9ce34f5

Please sign in to comment.