Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tempdir delegate (#57) #58

Merged
merged 5 commits into from
Nov 14, 2023
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
2 changes: 1 addition & 1 deletion test/caller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ var (
}()
// CallerTestErrorf provides the file with the line number of the `Errorf`
// call in testing.
CallerTestErrorf = path.Join(SourceDir, "testing.go:176")
CallerTestErrorf = path.Join(SourceDir, "testing.go:180")
// CallerGomockErrorf provides the file with the line number of the
// `Errorf` call in gomock.
CallerGomockErrorf = path.Join(SourceDir, "gomock.go:61")
Expand Down
6 changes: 5 additions & 1 deletion test/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ type Cleanuper interface {
// can be used as a drop in replacement for `testing.T` in various libraries
// to check for expected test failures.
type Tester struct {
Test
sync.Synchronizer
t Test
wg sync.WaitGroup
Expand Down Expand Up @@ -159,6 +158,11 @@ func (t *Tester) Name() string {
return t.t.Name()
}

// TempDir delegates the request to the parent test context.
func (t *Tester) TempDir() string {
return t.t.TempDir()
}

// Helper delegates request to the parent test context.
func (t *Tester) Helper() {
t.t.Helper()
Expand Down
7 changes: 7 additions & 0 deletions test/testing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ type ParamParam struct {
expect bool
}

func TestTempDir(t *testing.T) {
test.New[ParamParam](t, ParamParam{expect: true}).
Run(func(t test.Test, param ParamParam) {
assert.NotEmpty(t, t.TempDir())
})
}

func TestNameCastFallback(t *testing.T) {
test.New[ParamParam](t, ParamParam{name: "value"}).
Run(func(t test.Test, param ParamParam) {
Expand Down