diff --git a/modules/aws/rds_test.go b/modules/aws/rds_test.go index 5946292dc..213a22981 100644 --- a/modules/aws/rds_test.go +++ b/modules/aws/rds_test.go @@ -22,7 +22,7 @@ func TestGetRecommendedRdsInstanceTypeHappyPath(t *testing.T) { name: "US region, mysql, first offering available", region: "us-east-2", databaseEngine: "mysql", - databaseEngineVersion: "8.0.21", + databaseEngineVersion: "8.0.32", instanceTypes: []string{"db.t2.micro", "db.t3.micro"}, expected: "db.t2.micro", }, @@ -107,14 +107,14 @@ func TestGetRecommendedRdsInstanceTypeErrors(t *testing.T) { name: "Invalid instance types", region: "us-east-2", databaseEngine: "mysql", - databaseEngineVersion: "8.0.21", + databaseEngineVersion: "8.0.32", instanceTypes: []string{"garbage"}, }, { name: "Region has no instance type available", region: "eu-north-1", databaseEngine: "mysql", - databaseEngineVersion: "8.0.21", + databaseEngineVersion: "8.0.32", instanceTypes: []string{"db.t2.micro"}, }, { diff --git a/modules/terraform/init.go b/modules/terraform/init.go index e1cb17730..128fcd458 100644 --- a/modules/terraform/init.go +++ b/modules/terraform/init.go @@ -27,6 +27,10 @@ func InitE(t testing.TestingT, options *Options) (string, error) { if options.MigrateState { args = append(args, "-migrate-state", "-force-copy") } + // Append no-color option if needed + if options.NoColor { + args = append(args, "-no-color") + } args = append(args, FormatTerraformBackendConfigAsArgs(options.BackendConfig)...) args = append(args, FormatTerraformPluginDirAsArgs(options.PluginDir)...) diff --git a/modules/terraform/init_test.go b/modules/terraform/init_test.go index d98e94f48..3198c5234 100644 --- a/modules/terraform/init_test.go +++ b/modules/terraform/init_test.go @@ -132,3 +132,22 @@ func TestInitBackendMigration(t *testing.T) { _, err = InitE(t, options) assert.NoError(t, err, "Backend initialization with changed configuration should success with -migrate-state option") } + +func TestInitNoColorOption(t *testing.T) { + t.Parallel() + + testFolder, err := files.CopyTerraformFolderToTemp("../../test/fixtures/terraform-no-error", t.Name()) + require.NoError(t, err) + + options := WithDefaultRetryableErrors(t, &Options{ + TerraformDir: testFolder, + NoColor: true, + }) + + out := InitAndApply(t, options) + + require.Contains(t, out, "Hello, World") + + // Check that NoColor correctly doesn't output the colour escape codes which look like [0m, or [32m + require.NotRegexp(t, `\[\d*m`, out, "Output should not contain color escape codes") +}