Skip to content

Commit 817f3cf

Browse files
committed
bug: added basic test to detect stack files
1 parent bfcf295 commit 817f3cf

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
unit "unit3" {
3+
source = "../units/template"
4+
path = "unit3"
5+
}
6+
7+
unit "unit4" {
8+
source = "../units/template"
9+
path = "unit4"
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
unit "unit1" {
2+
source = "../units/template"
3+
path = "unit1"
4+
}
5+
6+
unit "unit2" {
7+
source = "../units/template"
8+
path = "unit2"
9+
}

test/fixtures/regressions/multiple-stacks/units/template/main.tf

Whitespace-only changes.

test/fixtures/regressions/multiple-stacks/units/template/terragrunt.hcl

Whitespace-only changes.

test/integration_regressions_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const (
1919
testFixtureDependencyEmptyConfigPath = "fixtures/regressions/dependency-empty-config-path"
2020
testFixtureParsingDeprecated = "fixtures/parsing/exposed-include-with-deprecated-inputs"
2121
testFixtureSensitiveValues = "fixtures/regressions/sensitive-values"
22+
testFixtureStackDetection = "fixtures/regressions/multiple-stacks"
2223
)
2324

2425
func TestNoAutoInit(t *testing.T) {
@@ -371,3 +372,23 @@ func TestSensitiveValues(t *testing.T) {
371372
assert.Equal(t, "25", passwordLengthStr,
372373
"Password length should match dev password")
373374
}
375+
376+
func TestMultipleStacksDetection(t *testing.T) {
377+
t.Parallel()
378+
379+
helpers.CleanupTerraformFolder(t, testFixtureStackDetection)
380+
tmpEnvPath := helpers.CopyEnvironment(t, testFixtureStackDetection)
381+
rootPath := util.JoinPath(tmpEnvPath, testFixtureStackDetection, "live")
382+
383+
_, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt stack generate --working-dir "+rootPath)
384+
385+
require.NoError(t, err)
386+
387+
assert.Contains(t, stderr, "terragrunt.stack.hcl")
388+
assert.Contains(t, stderr, "unit1")
389+
assert.Contains(t, stderr, "unit2")
390+
391+
assert.NotContains(t, stderr, "appv2.terragrunt.stack.hcl")
392+
assert.NotContains(t, stderr, "unit4")
393+
assert.NotContains(t, stderr, "unit3")
394+
}

0 commit comments

Comments
 (0)