Skip to content

Commit

Permalink
test: fix clock matcher tests to work in any timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
ydylla committed Aug 5, 2024
1 parent 59a262a commit 2ebc531
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions modules/l4clock/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package l4clock

import (
"context"
"fmt"
"io"
"net"
"testing"
Expand All @@ -41,8 +42,8 @@ func Test_MatchClock_Match(t *testing.T) {
shouldMatch bool
}

tNowMinus5Minutes := time.Now().Add(time.Minute * 5 * (-1)).Format(time.TimeOnly)
tNowPlus5Minutes := time.Now().Add(time.Minute * 5).Format(time.TimeOnly)
tNowMinus5Minutes := time.Now().UTC().Add(time.Minute * 5 * (-1)).Format(time.TimeOnly)
tNowPlus5Minutes := time.Now().UTC().Add(time.Minute * 5).Format(time.TimeOnly)

tests := []test{
{matcher: &MatchClock{}, data: []byte{}, shouldMatch: true},
Expand All @@ -59,7 +60,7 @@ func Test_MatchClock_Match(t *testing.T) {
defer cancel()

for i, tc := range tests {
func() {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
err := tc.matcher.Provision(ctx)
assertNoError(t, err)

Expand All @@ -81,11 +82,11 @@ func Test_MatchClock_Match(t *testing.T) {

if matched != tc.shouldMatch {
if tc.shouldMatch {
t.Fatalf("test %d: matcher did not match | %+v\n", i, tc.matcher)
t.Fatalf("matcher did not match | %+v\n", tc.matcher)
} else {
t.Fatalf("test %d: matcher should not match | %+v\n", i, tc.matcher)
t.Fatalf("matcher should not match | %+v\n", tc.matcher)
}
}
}()
})
}
}

0 comments on commit 2ebc531

Please sign in to comment.