@@ -233,6 +233,32 @@ func TestDetailedExitCodeChangesPresentAll(t *testing.T) {
233233 assert .Equal (t , 2 , exitCode .Get ())
234234}
235235
236+ func TestDetailedExitCodeChangesUnit (t * testing.T ) {
237+ t .Parallel ()
238+
239+ testFixturePath := filepath .Join (testFixtureDetailedExitCode , "changes" )
240+
241+ helpers .CleanupTerraformFolder (t , testFixturePath )
242+ tmpEnvPath := helpers .CopyEnvironment (t , testFixturePath )
243+ rootPath := util .JoinPath (tmpEnvPath , testFixturePath )
244+ ctx := t .Context ()
245+
246+ _ , _ , err := helpers .RunTerragruntCommandWithOutputWithContext (t , ctx , "terragrunt run --all --log-level trace --non-interactive --working-dir " + rootPath + " -- apply" )
247+ require .NoError (t , err )
248+
249+ // delete example.txt from rootPath/app1 to have changes in one unit
250+ err = os .Remove (filepath .Join (rootPath , "app1" , "example.txt" ))
251+ require .NoError (t , err )
252+
253+ // check that the exit code is 2 when there are changes in one unit
254+ var exitCode tf.DetailedExitCode
255+ ctx = tf .ContextWithDetailedExitCode (ctx , & exitCode )
256+
257+ _ , _ , err = helpers .RunTerragruntCommandWithOutputWithContext (t , ctx , "terragrunt run --all --log-level trace --non-interactive --working-dir " + rootPath + " -- plan -detailed-exitcode" )
258+ require .NoError (t , err )
259+ assert .Equal (t , 2 , exitCode .Get ())
260+ }
261+
236262func TestDetailedExitCodeFailOnFirstRun (t * testing.T ) {
237263 t .Parallel ()
238264
0 commit comments