From 81bc33b83e40004cc4058e8b16b951af2cc3398e Mon Sep 17 00:00:00 2001 From: Henry Snopek Date: Fri, 21 Oct 2022 15:35:42 -0500 Subject: [PATCH] refactor: remove gotest.tools/v3 usage --- docker_test.go | 16 ++++++++-------- go.mod | 2 +- logconsumer_test.go | 6 +++--- wait/http_test.go | 5 +++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/docker_test.go b/docker_test.go index 2655796c5d..c1496a4b71 100644 --- a/docker_test.go +++ b/docker_test.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "log" + "path" // Import mysql into the scope of this package (required) "io" @@ -26,7 +27,6 @@ import ( "github.com/go-redis/redis/v8" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gotest.tools/v3/fs" "github.com/docker/docker/errdefs" @@ -1344,8 +1344,8 @@ func TestReadTCPropsFile(t *testing.T) { }) t.Run("HOME does not contain TC props file", func(t *testing.T) { - tmpDir := fs.NewDir(t, os.TempDir()) - t.Setenv("HOME", tmpDir.Path()) + tmpDir := t.TempDir() + t.Setenv("HOME", tmpDir) config := configureTC() @@ -1353,8 +1353,8 @@ func TestReadTCPropsFile(t *testing.T) { }) t.Run("HOME does not contain TC props file - TESTCONTAINERS_ env is set", func(t *testing.T) { - tmpDir := fs.NewDir(t, os.TempDir()) - t.Setenv("HOME", tmpDir.Path()) + tmpDir := t.TempDir() + t.Setenv("HOME", tmpDir) t.Setenv("TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED", "true") config := configureTC() @@ -1560,12 +1560,12 @@ func TestReadTCPropsFile(t *testing.T) { } for i, tt := range tests { t.Run(fmt.Sprintf("[%d]", i), func(t *testing.T) { - tmpDir := fs.NewDir(t, os.TempDir()) - t.Setenv("HOME", tmpDir.Path()) + tmpDir := t.TempDir() + t.Setenv("HOME", tmpDir) for k, v := range tt.env { t.Setenv(k, v) } - if err := os.WriteFile(tmpDir.Join(".testcontainers.properties"), []byte(tt.content), 0o600); err != nil { + if err := os.WriteFile(path.Join(tmpDir, ".testcontainers.properties"), []byte(tt.content), 0o600); err != nil { t.Errorf("Failed to create the file: %v", err) return } diff --git a/go.mod b/go.mod index 03feb83860..e0ef552e0d 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,6 @@ require ( golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.8.2 - gotest.tools/v3 v3.4.0 ) require ( @@ -58,4 +57,5 @@ require ( google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect google.golang.org/grpc v1.47.0 // indirect google.golang.org/protobuf v1.28.0 // indirect + gotest.tools/v3 v3.4.0 // indirect ) diff --git a/logconsumer_test.go b/logconsumer_test.go index 53be320ecf..49527754e6 100644 --- a/logconsumer_test.go +++ b/logconsumer_test.go @@ -10,8 +10,8 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gotest.tools/v3/assert" "github.com/docker/docker/client" @@ -106,7 +106,7 @@ func Test_LogConsumerGetsCalled(t *testing.T) { // get rid of the server "ready" log g.Msgs = g.Msgs[1:] - assert.DeepEqual(t, []string{"echo hello\n", "echo there\n"}, g.Msgs) + assert.Equal(t, []string{"echo hello\n", "echo there\n"}, g.Msgs) CleanupContainer(t, ctx, c) } @@ -181,7 +181,7 @@ func Test_ShouldRecognizeLogTypes(t *testing.T) { <-g.Ack _ = c.StopLogProducer() - assert.DeepEqual(t, map[string]string{ + assert.Equal(t, map[string]string{ StdoutLog: "echo this-is-stdout\n", StderrLog: "echo this-is-stderr\n", }, g.LogTypes) diff --git a/wait/http_test.go b/wait/http_test.go index 6907e1fe32..93e11ae40d 100644 --- a/wait/http_test.go +++ b/wait/http_test.go @@ -11,6 +11,7 @@ import ( "net" "net/http" "os" + "path" "testing" "time" @@ -51,7 +52,7 @@ func TestHTTPStrategyWaitUntilReady(t *testing.T) { return } - capath := workdir + "/testdata/root.pem" + capath := path.Join(workdir, "testdata", "root.pem") cafile, err := os.ReadFile(capath) if err != nil { t.Errorf("can't load ca file: %v", err) @@ -68,7 +69,7 @@ func TestHTTPStrategyWaitUntilReady(t *testing.T) { var i int dockerReq := testcontainers.ContainerRequest{ FromDockerfile: testcontainers.FromDockerfile{ - Context: workdir + "/testdata", + Context: path.Join(workdir, "/testdata"), }, ExposedPorts: []string{"6443/tcp"}, WaitingFor: wait.NewHTTPStrategy("/ping").WithTLS(true, tlsconfig).