Skip to content

Commit

Permalink
refactor(suite): use local T interface consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicbarnes committed Sep 19, 2024
1 parent b993fe5 commit d1c7675
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
6 changes: 3 additions & 3 deletions suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
//
// For more advanced cases like using TestSuite.SharedDir or situations where
// multiple types are passed to Load, the TestSuite should be used directly.
func RunTestSuite[Input any, Output any](t *testing.T, dir string, fn func(t *testing.T, test Input) Output) {
func RunTestSuite[Input any, Output any](t T, dir string, fn func(t *testing.T, test Input) Output) {
t.Helper()

suite := TestSuite{
Expand Down Expand Up @@ -89,7 +89,7 @@ type TestSuite struct {
}

// Run loads and executes the test suite.
func (s *TestSuite) Run(t *testing.T) {
func (s *TestSuite) Run(t T) {
t.Helper()

hasOnly := false
Expand Down Expand Up @@ -147,7 +147,7 @@ func (s *TestSuite) Run(t *testing.T) {
}
}

func listSubDirs(t *testing.T, dir string) []string {
func listSubDirs(t T, dir string) []string {
t.Helper()

if dir == "" {
Expand Down
4 changes: 4 additions & 0 deletions testing.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package got

import "testing"

//go:generate mockgen -destination=testing_mock.go -package=got . T

type T interface {
Helper()
Fatal(...any)
Fatalf(string, ...any)
Run(string, func(*testing.T)) bool
}
32 changes: 32 additions & 0 deletions testing_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d1c7675

Please sign in to comment.