diff --git a/local/e2e/backend_test.go b/local/e2e/backend_test.go index b07aab01..2d77d357 100644 --- a/local/e2e/backend_test.go +++ b/local/e2e/backend_test.go @@ -43,11 +43,11 @@ func TestMain(m *testing.M) { func TestLocalBackend(t *testing.T) { c := NewParallelE2eCLI(t, binDir) - c.RunDocker( "context", "create", "local", "test-context").Assert(t, icmd.Success) + c.RunDocker("context", "create", "local", "test-context").Assert(t, icmd.Success) c.RunDocker("context", "use", "test-context").Assert(t, icmd.Success) t.Run("run", func(t *testing.T) { - res := c.RunDocker( "run", "-d", "nginx") + res := c.RunDocker("run", "-d", "nginx") containerName := strings.TrimSpace(res.Combined()) t.Cleanup(func() { _ = c.RunDockerOrFail("rm", "-f", containerName) @@ -57,14 +57,14 @@ func TestLocalBackend(t *testing.T) { }) t.Run("run with ports", func(t *testing.T) { - res := c.RunDocker( "run", "-d", "-p", "8080:80", "nginx") + res := c.RunDocker("run", "-d", "-p", "8080:80", "nginx") containerName := strings.TrimSpace(res.Combined()) t.Cleanup(func() { _ = c.RunDockerOrFail("rm", "-f", containerName) }) - res = c.RunDocker( "inspect", containerName) + res = c.RunDocker("inspect", containerName) res.Assert(t, icmd.Expected{Out: `"Status": "running"`}) - res = c.RunDocker( "ps") + res = c.RunDocker("ps") res.Assert(t, icmd.Expected{Out: "0.0.0.0:8080->80/tcp"}) }) diff --git a/tests/aci-e2e/e2e-aci_test.go b/tests/aci-e2e/e2e-aci_test.go index 7de7a460..126f2ec2 100644 --- a/tests/aci-e2e/e2e-aci_test.go +++ b/tests/aci-e2e/e2e-aci_test.go @@ -87,8 +87,8 @@ func TestLoginLogout(t *testing.T) { _ = deleteResourceGroup(rg) }) - res := c.RunDocker("context", "create", "aci", contextName, "--subscription-id", sID, "--resource-group", rg, "--location", location) - res = c.RunDocker("context", "use", contextName) + c.RunDocker("context", "create", "aci", contextName, "--subscription-id", sID, "--resource-group", rg, "--location", location) + res := c.RunDocker("context", "use", contextName) res.Assert(t, icmd.Expected{Out: contextName}) res = c.RunDocker("context", "ls") res.Assert(t, icmd.Expected{Out: contextName + " *"}) @@ -402,9 +402,8 @@ func TestCompose(t *testing.T) { t.Run("compose up", func(t *testing.T) { // Name of Compose project is taken from current folder "acie2e" - res := c.RunDocker("compose", "up", "-f", composeFile) - - res = c.RunDocker("ps") + c.RunDocker("compose", "up", "-f", composeFile) + res := c.RunDocker("ps") out := strings.Split(strings.TrimSpace(res.Stdout()), "\n") // Check three containers are running assert.Assert(t, is.Len(out, 4)) @@ -438,9 +437,8 @@ func TestCompose(t *testing.T) { }) t.Run("update", func(t *testing.T) { - res := c.RunDocker("compose", "up", "-f", composeFileMultiplePorts, "--project-name", composeProjectName) - - res = c.RunDocker("ps") + c.RunDocker("compose", "up", "-f", composeFileMultiplePorts, "--project-name", composeProjectName) + res := c.RunDocker("ps") out := strings.Split(strings.TrimSpace(res.Stdout()), "\n") // Check three containers are running assert.Assert(t, is.Len(out, 4)) @@ -481,9 +479,8 @@ func TestCompose(t *testing.T) { }) t.Run("down", func(t *testing.T) { - res := c.RunDocker("compose", "down", "--project-name", composeProjectName) - - res = c.RunDocker("ps") + c.RunDocker("compose", "down", "--project-name", composeProjectName) + res := c.RunDocker("ps") out := strings.Split(strings.TrimSpace(res.Stdout()), "\n") assert.Equal(t, len(out), 1) }) @@ -584,8 +581,8 @@ func createResourceGroup(sID, rgName string) error { } func createAciContextAndUseIt(t *testing.T, c *E2eCLI, sID, rgName string) { - res := c.RunDocker("context", "create", "aci", contextName, "--subscription-id", sID, "--resource-group", rgName, "--location", location) - res = c.RunDocker("context", "use", contextName) + c.RunDocker("context", "create", "aci", contextName, "--subscription-id", sID, "--resource-group", rgName, "--location", location) + res := c.RunDocker("context", "use", contextName) res.Assert(t, icmd.Expected{Out: contextName}) res = c.RunDocker("context", "ls") res.Assert(t, icmd.Expected{Out: contextName + " *"}) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 96d58f2c..25636554 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -357,8 +357,8 @@ func TestLegacyLogin(t *testing.T) { func TestUnsupportedCommand(t *testing.T) { c := NewParallelE2eCLI(t, binDir) - res := c.RunDocker("context", "create", "example", "test-example") - res = c.RunDockerOrFail("--context", "test-example", "images") + c.RunDocker("context", "create", "example", "test-example") + res := c.RunDockerOrFail("--context", "test-example", "images") res.Assert(t, icmd.Expected{ ExitCode: 1, Err: `Command "images" not available in current context (test-example), you can use the "default" context to run this command`, diff --git a/tests/ecs-e2e/e2e-ecs_test.go b/tests/ecs-e2e/e2e-ecs_test.go index 99716a64..9c2b6ec0 100644 --- a/tests/ecs-e2e/e2e-ecs_test.go +++ b/tests/ecs-e2e/e2e-ecs_test.go @@ -71,8 +71,8 @@ func TestSecrets(t *testing.T) { }) t.Run("rm secret", func(t *testing.T) { - res := cmd.RunDocker("secret", "rm", secretName) - res = cmd.RunDocker("secret", "list") + cmd.RunDocker("secret", "rm", secretName) + res := cmd.RunDocker("secret", "list") assert.Check(t, !strings.Contains(res.Stdout(), secretName)) }) } @@ -132,7 +132,7 @@ func setupTest(t *testing.T) (*E2eCLI, string) { if localTestProfile != "" { region := os.Getenv("TEST_AWS_REGION") assert.Check(t, region != "") - res = c.RunDocker("context", "create", "ecs", contextName, "--profile", localTestProfile, "--region", region) + c.RunDocker("context", "create", "ecs", contextName, "--profile", localTestProfile, "--region", region) } else { profile := contextName region := os.Getenv("AWS_DEFAULT_REGION") @@ -141,7 +141,7 @@ func setupTest(t *testing.T) (*E2eCLI, string) { assert.Check(t, keyID != "") assert.Check(t, secretKey != "") assert.Check(t, region != "") - res = c.RunDocker("context", "create", "ecs", contextName, "--profile", profile, "--region", region, "--secret-key", secretKey, "--key-id", keyID) + c.RunDocker("context", "create", "ecs", contextName, "--profile", profile, "--region", region, "--secret-key", secretKey, "--key-id", keyID) } res = c.RunDocker("context", "use", contextName) res.Assert(t, icmd.Expected{Out: contextName}) diff --git a/tests/framework/e2e.go b/tests/framework/e2e.go index 2d56892c..17dcf459 100644 --- a/tests/framework/e2e.go +++ b/tests/framework/e2e.go @@ -53,7 +53,7 @@ func init() { type E2eCLI struct { BinDir string ConfigDir string - test *testing.T + test *testing.T } // NewParallelE2eCLI returns a configured TestE2eCLI with t.Parallel() set @@ -163,7 +163,7 @@ func (c *E2eCLI) NewDockerCmd(args ...string) icmd.Cmd { // RunDockerOrFail runs a docker command and returns a result func (c *E2eCLI) RunDockerOrFail(args ...string) *icmd.Result { - fmt.Printf(" [%s] docker %s\n", c.test.Name() , strings.Join(args, " ") ) + fmt.Printf(" [%s] docker %s\n", c.test.Name(), strings.Join(args, " ")) return icmd.RunCmd(c.NewDockerCmd(args...)) }