Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions backend/internal/api/v1/handlers/handlers_test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
1 change: 1 addition & 0 deletions backend/internal/store/pg/otp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down