|
7 | 7 | "testing"
|
8 | 8 |
|
9 | 9 | hcl "github.com/hashicorp/hcl/v2"
|
10 |
| - "github.com/stretchr/testify/assert" |
11 | 10 | "github.com/terraform-linters/tflint/tflint"
|
12 | 11 | "github.com/xeipuuv/gojsonschema"
|
13 | 12 | )
|
@@ -266,22 +265,25 @@ func Test_sarifPrint(t *testing.T) {
|
266 | 265 | }
|
267 | 266 |
|
268 | 267 | for _, tc := range cases {
|
269 |
| - stdout := &bytes.Buffer{} |
270 |
| - stderr := &bytes.Buffer{} |
271 |
| - formatter := &Formatter{Stdout: stdout, Stderr: stderr, Format: "sarif"} |
| 268 | + t.Run(tc.Name, func(t *testing.T) { |
| 269 | + stdout := &bytes.Buffer{} |
| 270 | + stderr := &bytes.Buffer{} |
| 271 | + formatter := &Formatter{Stdout: stdout, Stderr: stderr, Format: "sarif"} |
272 | 272 |
|
273 |
| - formatter.Print(tc.Issues, tc.Error, map[string][]byte{}) |
| 273 | + formatter.Print(tc.Issues, tc.Error, map[string][]byte{}) |
274 | 274 |
|
275 |
| - if stdout.String() != tc.Stdout { |
276 |
| - t.Fatalf("Failed %s test: expected=%s, stdout=%s", tc.Name, tc.Stdout, stdout.String()) |
277 |
| - } |
| 275 | + if stdout.String() != tc.Stdout { |
| 276 | + t.Fatalf("Failed %s test: expected=%s, stdout=%s", tc.Name, tc.Stdout, stdout.String()) |
| 277 | + } |
278 | 278 |
|
279 |
| - schemaLoader := gojsonschema.NewReferenceLoader("http://json.schemastore.org/sarif-2.1.0") |
280 |
| - result, err := gojsonschema.Validate(schemaLoader, gojsonschema.NewStringLoader(stdout.String())) |
281 |
| - |
282 |
| - assert.NoError(t, err) |
283 |
| - for _, err := range result.Errors() { |
284 |
| - t.Error(err) |
285 |
| - } |
| 279 | + schemaLoader := gojsonschema.NewReferenceLoader("http://json.schemastore.org/sarif-2.1.0") |
| 280 | + result, err := gojsonschema.Validate(schemaLoader, gojsonschema.NewStringLoader(stdout.String())) |
| 281 | + if err != nil { |
| 282 | + t.Error(err) |
| 283 | + } |
| 284 | + for _, err := range result.Errors() { |
| 285 | + t.Error(err) |
| 286 | + } |
| 287 | + }) |
286 | 288 | }
|
287 | 289 | }
|
0 commit comments