diff --git a/src/internal/kopia/conn_test.go b/src/internal/kopia/conn_test.go index 36a2bcdfd..b849176dd 100644 --- a/src/internal/kopia/conn_test.go +++ b/src/internal/kopia/conn_test.go @@ -23,7 +23,7 @@ import ( ) func openKopiaRepo( - t *testing.T, + t tester.TestT, ctx context.Context, //revive:disable-line:context-as-argument ) (*conn, error) { st := storeTD.NewPrefixedS3Storage(t) diff --git a/src/internal/tester/context.go b/src/internal/tester/context.go index 7bb5b98c6..1e6e1ccc7 100644 --- a/src/internal/tester/context.go +++ b/src/internal/tester/context.go @@ -3,7 +3,6 @@ package tester import ( "context" "os" - "testing" "github.com/alcionai/clues" "github.com/google/uuid" @@ -11,7 +10,7 @@ import ( "github.com/alcionai/corso/src/pkg/logger" ) -func NewContext(t *testing.T) (context.Context, func()) { +func NewContext(t TestT) (context.Context, func()) { level := logger.LLInfo format := logger.LFText @@ -34,7 +33,7 @@ func NewContext(t *testing.T) (context.Context, func()) { } func WithContext( - t *testing.T, + t TestT, ctx context.Context, //revive:disable-line:context-as-argument ) (context.Context, func()) { ls := logger.Settings{ @@ -48,7 +47,7 @@ func WithContext( } func enrichTestCtx( - t *testing.T, + t TestT, ctx context.Context, //revive:disable-line:context-as-argument ) context.Context { if t == nil { diff --git a/src/internal/tester/tester.go b/src/internal/tester/tester.go index 10cb070f7..909c5b04c 100644 --- a/src/internal/tester/tester.go +++ b/src/internal/tester/tester.go @@ -7,6 +7,7 @@ import ( "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) // AreSameFunc asserts whether the two funcs are the same func. @@ -26,8 +27,15 @@ func AreSameFunc(t *testing.T, expect, have any) { ) } +type TestT interface { + Logf(format string, args ...any) + Name() string + TempDir() string + require.TestingT +} + // LogTimeOfTest logs the test name and the time that it was run. -func LogTimeOfTest(t *testing.T) string { +func LogTimeOfTest(t TestT) string { now := time.Now().UTC().Format(time.RFC3339Nano) name := t.Name() diff --git a/src/pkg/repository/repository_test.go b/src/pkg/repository/repository_test.go index b051581f0..8f9725dc2 100644 --- a/src/pkg/repository/repository_test.go +++ b/src/pkg/repository/repository_test.go @@ -126,7 +126,7 @@ func (suite *RepositoryIntegrationSuite) TestInitialize() { table := []struct { name string account account.Account - storage func(*testing.T) storage.Storage + storage func(tester.TestT) storage.Storage errCheck assert.ErrorAssertionFunc }{ { diff --git a/src/pkg/storage/testdata/storage.go b/src/pkg/storage/testdata/storage.go index f2a181d43..d6703af20 100644 --- a/src/pkg/storage/testdata/storage.go +++ b/src/pkg/storage/testdata/storage.go @@ -2,7 +2,6 @@ package testdata import ( "os" - "testing" "github.com/alcionai/clues" "github.com/stretchr/testify/require" @@ -28,7 +27,7 @@ var AWSStorageCredEnvs = []string{ // Uses t.TempDir() to generate a unique config storage and caching directory for this // test. Suites that need to identify this value can retrieve it again from the common // configs. -func NewPrefixedS3Storage(t *testing.T) storage.Storage { +func NewPrefixedS3Storage(t tester.TestT) storage.Storage { now := tester.LogTimeOfTest(t) cfg, err := tconfig.ReadTestConfig()