@@ -48,6 +48,7 @@ const (
4848 testFixtureStackNestedOutputs = "fixtures/stacks/nested-outputs"
4949 testFixtureStackNoValidation = "fixtures/stacks/no-validation"
5050 testFixtureStackTerragruntDir = "fixtures/stacks/terragrunt-dir"
51+ testFixtureStacksAllNoStackDir = "fixtures/stacks/all-no-stack-dir"
5152 testFixtureStackNoDotTerragruntStackOutput = "fixtures/stacks/no-dot-terragrunt-stack-output"
5253)
5354
@@ -1047,18 +1048,6 @@ func TestStacksNoStackDirDirectoryCreated(t *testing.T) {
10471048 assert .NoDirExists (t , path )
10481049}
10491050
1050- func TestStacksNoStackCommandFail (t * testing.T ) {
1051- t .Parallel ()
1052-
1053- helpers .CleanupTerraformFolder (t , testFixtureNoStackNoDir )
1054- tmpEnvPath := helpers .CopyEnvironment (t , testFixtureNoStackNoDir )
1055- rootPath := util .JoinPath (tmpEnvPath , testFixtureNoStackNoDir , "live" )
1056-
1057- _ , _ , err := helpers .RunTerragruntCommandWithOutput (t , "terragrunt stack run apply --non-interactive --working-dir " + rootPath )
1058- require .Error (t , err )
1059- assert .Contains (t , err .Error (), "Stack directory does not exist or is not accessible" )
1060- }
1061-
10621051func TestStacksGeneratePrintWarning (t * testing.T ) {
10631052 t .Parallel ()
10641053
@@ -1354,6 +1343,36 @@ func TestStackTerragruntDir(t *testing.T) {
13541343 assert .Contains (t , out , `terragrunt_dir = "./tennant_1"` )
13551344}
13561345
1346+ func TestStackRunAllNoStackDir (t * testing.T ) {
1347+ t .Parallel ()
1348+
1349+ helpers .CleanupTerraformFolder (t , testFixtureStacksAllNoStackDir )
1350+ tmpEnvPath := helpers .CopyEnvironment (t , testFixtureStacksAllNoStackDir )
1351+
1352+ rootPath := util .JoinPath (tmpEnvPath , testFixtureStacksAllNoStackDir , "live" )
1353+
1354+ helpers .RunTerragrunt (t , "terragrunt stack generate --working-dir " + rootPath )
1355+
1356+ // Verify that no .terragrunt-stack directory was created since all units have no_dot_terragrunt_stack = true
1357+ stackDir := util .JoinPath (rootPath , ".terragrunt-stack" )
1358+ stackDirExists := util .FileExists (stackDir )
1359+ t .Logf ("Stack directory exists: %v" , stackDirExists )
1360+
1361+ // Verify that units were generated in the same directory as terragrunt.stack.hcl
1362+ expectedUnits := []string {"foo" , "bar" }
1363+ for _ , unit := range expectedUnits {
1364+ unitPath := util .JoinPath (rootPath , unit )
1365+ assert .True (t , util .FileExists (unitPath ), "Expected unit %s to exist in root directory" , unit )
1366+ assert .True (t , util .FileExists (util .JoinPath (unitPath , "terragrunt.hcl" )), "Expected terragrunt.hcl to exist in unit %s" , unit )
1367+ }
1368+
1369+ stdout , _ , err := helpers .RunTerragruntCommandWithOutput (t , "terragrunt stack run plan --non-interactive --working-dir " + rootPath )
1370+ require .NoError (t , err , "Expected stack run to succeed when all units have no_dot_terragrunt_stack = true" )
1371+
1372+ assert .Contains (t , stdout , "Changes to Outputs:" )
1373+ assert .Contains (t , stdout , "+ test = \" value\" " )
1374+ }
1375+
13571376func TestStackOutputWithNoDotTerragruntStack (t * testing.T ) {
13581377 t .Parallel ()
13591378
0 commit comments