From 1ae4d81948e1d3cba4f854a012040d35e703a071 Mon Sep 17 00:00:00 2001 From: l-m Date: Fri, 3 Oct 2025 10:21:14 +1000 Subject: [PATCH 1/3] fix(api): deepequal in tests handles time.Time --- .../api/v1/handlers/handlers_test/main_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/internal/api/v1/handlers/handlers_test/main_test.go b/backend/internal/api/v1/handlers/handlers_test/main_test.go index 3dcfd5c..f9839be 100644 --- a/backend/internal/api/v1/handlers/handlers_test/main_test.go +++ b/backend/internal/api/v1/handlers/handlers_test/main_test.go @@ -172,6 +172,18 @@ func compareStructs[T any](expected, actual T) error { expectedField := expectedValue.Field(i) actualField := actualValue.Field(i) + // handle time.Time + if expectedField.Type() == reflect.TypeOf(time.Time{}) && actualField.Type() == reflect.TypeOf(time.Time{}) { + et := expectedField.Interface().(time.Time) + at := actualField.Interface().(time.Time) + // Treat zero times as equal only if both are zero; otherwise use Equal + if !(et.IsZero() && at.IsZero()) && !et.Equal(at) { + diffs = append(diffs, fmt.Sprintf(" field '%s': expected %v (type %s), got %v (type %s)", + field.Name, et, expectedField.Type(), at, actualField.Type())) + } + continue + } + // reflect.DeepEqual handles most built-in types, slices, maps, and // nested structs recursively. if !reflect.DeepEqual(expectedField.Interface(), actualField.Interface()) { From ae06c634772e2eb0edaaef81d00694a9dddac362 Mon Sep 17 00:00:00 2001 From: l-m Date: Fri, 3 Oct 2025 10:25:14 +1000 Subject: [PATCH 2/3] fix(api): pass lint --- backend/internal/api/v1/handlers/handlers_test/main_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/api/v1/handlers/handlers_test/main_test.go b/backend/internal/api/v1/handlers/handlers_test/main_test.go index f9839be..d982d12 100644 --- a/backend/internal/api/v1/handlers/handlers_test/main_test.go +++ b/backend/internal/api/v1/handlers/handlers_test/main_test.go @@ -177,7 +177,7 @@ func compareStructs[T any](expected, actual T) error { et := expectedField.Interface().(time.Time) at := actualField.Interface().(time.Time) // Treat zero times as equal only if both are zero; otherwise use Equal - if !(et.IsZero() && at.IsZero()) && !et.Equal(at) { + if (!et.IsZero() || !at.IsZero()) && !et.Equal(at) { diffs = append(diffs, fmt.Sprintf(" field '%s': expected %v (type %s), got %v (type %s)", field.Name, et, expectedField.Type(), at, actualField.Type())) } From 7eb0e6bcd1336b1154771f16f8ba673dc68a0e85 Mon Sep 17 00:00:00 2001 From: l-m Date: Fri, 3 Oct 2025 10:29:26 +1000 Subject: [PATCH 3/3] fix(api): lintuh --- backend/internal/store/pg/otp_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/internal/store/pg/otp_test.go b/backend/internal/store/pg/otp_test.go index 2a7ef00..695dbaa 100644 --- a/backend/internal/store/pg/otp_test.go +++ b/backend/internal/store/pg/otp_test.go @@ -174,6 +174,7 @@ func TestActiveExists(t *testing.T) { } if otp == nil { t.Fatalf("OTP should exist") + panic("linter stop being stupid") } expected := store.OTPEntry{ Zid: zid,