Skip to content

Commit

Permalink
Add test to exclude by action
Browse files Browse the repository at this point in the history
  • Loading branch information
denis256 committed Nov 15, 2024
1 parent d05d576 commit 806a153
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exclude {
if = true
actions = ["apply"]
exclude_dependencies = true
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exclude {
if = true
actions = ["plan"]
exclude_dependencies = true
}
24 changes: 24 additions & 0 deletions test/integration_exclude_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
const (
testExcludeByDefault = "fixtures/exclude/exclude-default"
testExcludeDisabled = "fixtures/exclude/exclude-disabled"
testExcludeByAction = "fixtures/exclude/exclude-by-action"
)

func TestExcludeByDefault(t *testing.T) {
Expand Down Expand Up @@ -43,3 +44,26 @@ func TestExcludeDisabled(t *testing.T) {
assert.Contains(t, stderr, "app1")
assert.Contains(t, stderr, "app2")
}

func TestExcludeApply(t *testing.T) {
t.Parallel()

cleanupTerraformFolder(t, testExcludeByAction)
tmpEnvPath := helpers.CopyEnvironment(t, testExcludeByAction)
rootPath := util.JoinPath(tmpEnvPath, testExcludeByAction)

_, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all plan --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)

require.NoError(t, err)

assert.Contains(t, stderr, "exclude-apply")
assert.NotContains(t, stderr, "exclude-plan")

_, stderr, err = helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)

require.NoError(t, err)

// should be applied only exclude-plan
assert.Contains(t, stderr, "exclude-plan")
assert.NotContains(t, stderr, "exclude-apply")
}

0 comments on commit 806a153

Please sign in to comment.