Skip to content

Commit dc489ee

Browse files
committed
Apply lint improvements to TestTerragruntPlanAllOutput
- Use t.Chdir() instead of manual directory change with cleanup - Use t.Logf() instead of fmt.Printf() for test output - Remove t.Parallel() since t.Chdir() requires non-parallel execution
1 parent c4c3289 commit dc489ee

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

test/integration_test.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4261,21 +4261,13 @@ func TestVersionIsInvokedInDifferentDirectory(t *testing.T) {
42614261
}
42624262

42634263
func TestTerragruntPlanAllOutput(t *testing.T) {
4264-
t.Parallel()
42654264

42664265
helpers.CleanupTerraformFolder(t, testFixturePlanOutput)
42674266
tmpEnvPath := helpers.CopyEnvironment(t, testFixturePlanOutput)
42684267

42694268
outDir := filepath.Join(tmpEnvPath, "plans")
42704269
pwd := filepath.Join(tmpEnvPath, testFixturePlanOutput)
4271-
{
4272-
originalDir, err := os.Getwd()
4273-
require.NoError(t, err)
4274-
t.Cleanup(func() {
4275-
require.NoError(t, os.Chdir(originalDir))
4276-
})
4277-
require.NoError(t, os.Chdir(pwd))
4278-
}
4270+
t.Chdir(pwd)
42794271

42804272
cmd := fmt.Sprintf("terragrunt plan --all --non-interactive --out-dir %s --working-dir %s ", outDir, ".")
42814273
var (
@@ -4286,9 +4278,8 @@ func TestTerragruntPlanAllOutput(t *testing.T) {
42864278
err := helpers.RunTerragruntCommand(t, cmd, &stdout, &stderr)
42874279
require.NoError(t, err)
42884280

4289-
output := stdout.String()
4290-
errOutput := stderr.String()
4291-
fmt.Printf("STDERR is %s.\n STDOUT is %s", errOutput, output)
4281+
t.Logf("STDOUT: %s", stdout.String())
4282+
t.Logf("STDERR: %s", stderr.String())
42924283

42934284
assert.FileExists(t, filepath.Join(outDir, "vnet", "tfplan.tfplan"))
42944285
assert.FileExists(t, filepath.Join(outDir, "resource-group", "tfplan.tfplan"))
@@ -4307,4 +4298,3 @@ func TestMixedStackConfigIgnored(t *testing.T) {
43074298
require.NotContains(t, stderr, "Error: Unsupported block type")
43084299
require.NotContains(t, stderr, "Blocks of type \"unit\" are not expected here")
43094300
}
4310-
}

0 commit comments

Comments
 (0)