Skip to content

Commit

Permalink
fix: tempdir delegate (#57)
Browse files Browse the repository at this point in the history
Signed-off-by: tkrop <[email protected]>
  • Loading branch information
tkrop authored Nov 14, 2023
1 parent f6f9ca6 commit 665c1b8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
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

0 comments on commit 665c1b8

Please sign in to comment.