|
6 | 6 | "fmt" |
7 | 7 | "os" |
8 | 8 | "path/filepath" |
| 9 | + "sort" |
9 | 10 | "testing" |
10 | 11 |
|
11 | 12 | "github.com/gruntwork-io/terragrunt/codegen" |
@@ -714,7 +715,6 @@ func TestParseTerragruntConfigThreeLevels(t *testing.T) { |
714 | 715 | } |
715 | 716 |
|
716 | 717 | opts := mockOptionsForTestWithConfigPath(t, configPath) |
717 | | - |
718 | 718 | ctx := config.NewParsingContext(context.Background(), opts) |
719 | 719 |
|
720 | 720 | _, actualErr := config.ParseConfigString(ctx, configPath, cfg, nil) |
@@ -1127,20 +1127,38 @@ func TestFindConfigFilesIgnoresTerraformDataDirEnvRoot(t *testing.T) { |
1127 | 1127 | cwd, err := os.Getwd() |
1128 | 1128 | require.NoError(t, err) |
1129 | 1129 |
|
1130 | | - expected := []string{ |
1131 | | - filepath.Join(cwd, "../test/fixtures/config-files/ignore-terraform-data-dir/subdir/terragrunt.hcl"), |
1132 | | - filepath.Join(cwd, "../test/fixtures/config-files/ignore-terraform-data-dir/subdir/.terraform/modules/mod/terragrunt.hcl"), |
1133 | | - filepath.Join(cwd, "../test/fixtures/config-files/ignore-terraform-data-dir/subdir/.tf_data/modules/mod/terragrunt.hcl"), |
1134 | | - } |
1135 | 1130 | workingDir := filepath.Join(cwd, "../test/fixtures/config-files/ignore-terraform-data-dir/") |
1136 | 1131 | terragruntOptions, err := options.NewTerragruntOptionsForTest(workingDir) |
1137 | 1132 | require.NoError(t, err) |
1138 | 1133 | terragruntOptions.Env["TF_DATA_DIR"] = filepath.Join(workingDir, ".tf_data") |
1139 | 1134 |
|
1140 | 1135 | actual, err := config.FindConfigFilesInPath(workingDir, terragruntOptions) |
1141 | | - |
1142 | 1136 | require.NoError(t, err, "Unexpected error: %v", err) |
1143 | | - assert.ElementsMatch(t, expected, actual) |
| 1137 | + |
| 1138 | + // Create expected paths using filepath.Join for cross-platform compatibility |
| 1139 | + expected := []string{ |
| 1140 | + filepath.Join(cwd, "../test/fixtures/config-files/ignore-terraform-data-dir/subdir/terragrunt.hcl"), |
| 1141 | + filepath.Join(cwd, "../test/fixtures/config-files/ignore-terraform-data-dir/subdir/.terraform/modules/mod/terragrunt.hcl"), |
| 1142 | + filepath.Join(cwd, "../test/fixtures/config-files/ignore-terraform-data-dir/subdir/.tf_data/modules/mod/terragrunt.hcl"), |
| 1143 | + } |
| 1144 | + |
| 1145 | + // Sort both slices to ensure consistent order for comparison |
| 1146 | + sort.Strings(actual) |
| 1147 | + sort.Strings(expected) |
| 1148 | + |
| 1149 | + // Compare the paths using filepath.Clean to normalize them |
| 1150 | + normalizedActual := make([]string, len(actual)) |
| 1151 | + normalizedExpected := make([]string, len(expected)) |
| 1152 | + |
| 1153 | + for i, path := range actual { |
| 1154 | + normalizedActual[i] = filepath.Clean(path) |
| 1155 | + } |
| 1156 | + |
| 1157 | + for i, path := range expected { |
| 1158 | + normalizedExpected[i] = filepath.Clean(path) |
| 1159 | + } |
| 1160 | + |
| 1161 | + assert.Equal(t, normalizedExpected, normalizedActual) |
1144 | 1162 | } |
1145 | 1163 |
|
1146 | 1164 | func TestFindConfigFilesIgnoresDownloadDir(t *testing.T) { |
|
0 commit comments