diff --git a/internal/testutils/test_utils.go b/internal/testutils/test_utils.go index 97f90d64..68556eae 100644 --- a/internal/testutils/test_utils.go +++ b/internal/testutils/test_utils.go @@ -17,6 +17,7 @@ import ( "runtime" "testing" "time" + "unsafe" "github.com/google/go-cmp/cmp" ) @@ -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) diff --git a/tests/postgres/sample_test.go b/tests/postgres/sample_test.go index f2526317..0f192768 100644 --- a/tests/postgres/sample_test.go +++ b/tests/postgres/sample_test.go @@ -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)