diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 68e1fdc..0fa9bc8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,7 +3,7 @@ updates: - package-ecosystem: gomod directory: "/" schedule: - interval: weekly + interval: monthly groups: all: patterns: @@ -12,7 +12,7 @@ updates: - package-ecosystem: "github-actions" directory: "/" schedule: - interval: weekly + interval: monthly groups: all: patterns: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c331fb7..7881df0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,10 +10,10 @@ jobs: strategy: matrix: - go-version: [ "1.24", "1.25" ] + go-version: [ "1.25", "1.26" ] runs-on: ubuntu-latest env: - GOLANGCI_LINT_VERSION: v2.4.0 + GOLANGCI_LINT_VERSION: v2.11.3 steps: - name: Checkout code diff --git a/go.mod b/go.mod index ce61200..d1a14a3 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/hamba/testutils -go 1.24.0 +go 1.25.0 require ( github.com/ryanuber/go-glob v1.0.0 diff --git a/retry/retry.go b/retry/retry.go index 4c45673..8b36023 100644 --- a/retry/retry.go +++ b/retry/retry.go @@ -29,7 +29,7 @@ var DefaultPolicy = func() Policy { // TestingT represents a partial *testing.T. type TestingT interface { - Log(args ...interface{}) + Log(args ...any) FailNow() } @@ -106,35 +106,35 @@ func (t *SubT) Cleanup(fn func()) { } // Log adds a log line to the current test run. -func (t *SubT) Log(args ...interface{}) { +func (t *SubT) Log(args ...any) { t.log(fmt.Sprintln(args...)) } // Logf adds a formatted log line to the current test run. -func (t *SubT) Logf(format string, args ...interface{}) { +func (t *SubT) Logf(format string, args ...any) { t.log(fmt.Sprintf(format, args...)) } // Error adds a log line and fails the current test run. -func (t *SubT) Error(args ...interface{}) { +func (t *SubT) Error(args ...any) { t.log(fmt.Sprintln(args...)) t.Fail() } // Errorf adds a formatted log line and fails the current test run. -func (t *SubT) Errorf(format string, args ...interface{}) { +func (t *SubT) Errorf(format string, args ...any) { t.log(fmt.Sprintf(format, args...)) t.Fail() } // Fatal adds a log line, fails the current test run and exits immediately. -func (t *SubT) Fatal(args ...interface{}) { +func (t *SubT) Fatal(args ...any) { t.log(fmt.Sprintln(args...)) t.FailNow() } // Fatalf adds a formatted log line, fails the current test run and exits immediately. -func (t *SubT) Fatalf(format string, args ...interface{}) { +func (t *SubT) Fatalf(format string, args ...any) { t.log(fmt.Sprintf(format, args...)) t.FailNow() } diff --git a/retry/retry_test.go b/retry/retry_test.go index 319a520..bfa0648 100644 --- a/retry/retry_test.go +++ b/retry/retry_test.go @@ -15,7 +15,7 @@ const timeDeltaAllowed = float64(25 * time.Millisecond) func TestRun(t *testing.T) { mockT := new(MockTestingT) - mockT.On("Log", []interface{}{"test message"}).Once() + mockT.On("Log", []any{"test message"}).Once() mockT.On("FailNow").Once() var wg sync.WaitGroup @@ -59,7 +59,7 @@ func TestRunWith_AllowsPassing(t *testing.T) { func TestRunWith_HandlesFailing(t *testing.T) { mockT := new(MockTestingT) - mockT.On("Log", []interface{}{"test message"}).Once() + mockT.On("Log", []any{"test message"}).Once() mockT.On("FailNow").Once() var ( @@ -100,14 +100,12 @@ func TestRunWith_RunsCleanup(t *testing.T) { var wg sync.WaitGroup var runs int - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { retry.RunWith(mockT, retry.NewCounter(3, 10*time.Millisecond), func(t *retry.SubT) { t.Cleanup(func() { runs++ }) t.FailNow() }) - }() + }) wg.Wait() mockT.AssertExpectations(t) @@ -148,7 +146,7 @@ type MockTestingT struct { mock.Mock } -func (m *MockTestingT) Log(args ...interface{}) { +func (m *MockTestingT) Log(args ...any) { m.Called(args) } diff --git a/retry/rety_internal_test.go b/retry/rety_internal_test.go index a89b6aa..13a6322 100644 --- a/retry/rety_internal_test.go +++ b/retry/rety_internal_test.go @@ -83,12 +83,10 @@ func TestT(t *testing.T) { retryT := &SubT{} var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { test.fn(retryT) exited = false - }() + }) wg.Wait() assert.Equal(t, test.wantLog, retryT.logs)