|
1 | 1 | package config |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "strings" |
4 | 5 | "testing" |
5 | 6 | "time" |
6 | 7 |
|
@@ -130,16 +131,26 @@ func TestConfig(t *testing.T) { |
130 | 131 | } |
131 | 132 | }) |
132 | 133 |
|
133 | | - t.Run("Improve yaml parse error msg", func(t *testing.T) { |
134 | | - // TODO: Revisit this test - currently failing in CI |
135 | | - // Test validates YAML parsing error messages. May be related to JIRA tickets GCEA-1781, GCEA-1782. |
136 | | - // The testdata/space-issue.yaml file may not exist or parsing behavior differs in CI. |
137 | | - t.Skip("Skipping until YAML parse error handling can be reviewed - see GCEA-1781, GCEA-1782") |
138 | | - |
| 134 | + t.Run("should return helpful error for malformed YAML", func(t *testing.T) { |
| 135 | + // The space-issue.yaml has intentional formatting problems (inconsistent indentation) |
| 136 | + // This test verifies that the parser returns a helpful error message |
139 | 137 | args := []string{"yc", "-c", "testdata/space-issue.yaml"} |
140 | 138 | err := ParseFlags(args) |
141 | | - if err != nil { |
142 | | - t.Fatal(err) |
| 139 | + |
| 140 | + // Should return an error for malformed YAML |
| 141 | + if err == nil { |
| 142 | + t.Fatal("expected error for malformed YAML file, got nil") |
| 143 | + } |
| 144 | + |
| 145 | + // Error message should include the file path for context |
| 146 | + errMsg := err.Error() |
| 147 | + if !strings.Contains(errMsg, "space-issue.yaml") { |
| 148 | + t.Errorf("error message should include file path, got: %s", errMsg) |
| 149 | + } |
| 150 | + |
| 151 | + // Error message should include line number from YAML parser |
| 152 | + if !strings.Contains(errMsg, "line") { |
| 153 | + t.Errorf("error message should include line number, got: %s", errMsg) |
143 | 154 | } |
144 | 155 | }) |
145 | 156 | } |
0 commit comments