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
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: weekly
interval: monthly
groups:
all:
patterns:
Expand All @@ -12,7 +12,7 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
interval: monthly
groups:
all:
patterns:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var DefaultPolicy = func() Policy {

// TestingT represents a partial *testing.T.
type TestingT interface {
Log(args ...interface{})
Log(args ...any)
FailNow()
}

Expand Down Expand Up @@ -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()
}
Expand Down
12 changes: 5 additions & 7 deletions retry/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -148,7 +146,7 @@ type MockTestingT struct {
mock.Mock
}

func (m *MockTestingT) Log(args ...interface{}) {
func (m *MockTestingT) Log(args ...any) {
m.Called(args)
}

Expand Down
6 changes: 2 additions & 4 deletions retry/rety_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down