(t *testing.T)
| 32 | ) |
| 33 | |
| 34 | func Test_ReportJson(t *testing.T) { |
| 35 | filePaths := []string{"/path/to/file1.yaml", "/path/to/file2.yaml", "/path/to/file3.yaml"} |
| 36 | inputs := testInputsFor(filePaths) |
| 37 | ctx := context.Background() |
| 38 | testPolicy := createTestPolicy(t, ctx) |
| 39 | report, err := NewReport(inputs, testPolicy, nil, false, true, true) |
| 40 | assert.NoError(t, err) |
| 41 | |
| 42 | testEffectiveTime := testPolicy.EffectiveTime().UTC().Format(time.RFC3339Nano) |
| 43 | |
| 44 | expected := fmt.Sprintf(` |
| 45 | { |
| 46 | "success": false, |
| 47 | "filepaths": [ |
| 48 | { |
| 49 | "filepath": "/path/to/file1.yaml", |
| 50 | "violations": [ |
| 51 | { |
| 52 | "msg": "violation1" |
| 53 | } |
| 54 | ], |
| 55 | "warnings": [ |
| 56 | { |
| 57 | "msg": "warning1" |
| 58 | } |
| 59 | ], |
| 60 | "successes": [ |
| 61 | { |
| 62 | "msg": "success1" |
| 63 | } |
| 64 | ], |
| 65 | "success": false, |
| 66 | "success-count": 0 |
| 67 | }, |
| 68 | { |
| 69 | "filepath": "/path/to/file2.yaml", |
| 70 | "violations": [ |
| 71 | { |
| 72 | "msg": "violation2" |
| 73 | } |
| 74 | ], |
| 75 | "warnings": null, |
| 76 | "successes": null, |
| 77 | "success": false, |
| 78 | "success-count": 0 |
| 79 | }, |
| 80 | { |
| 81 | "filepath": "/path/to/file3.yaml", |
| 82 | "violations": null, |
| 83 | "warnings": null, |
| 84 | "successes": [ |
| 85 | { |
| 86 | "msg": "success3" |
| 87 | } |
| 88 | ], |
| 89 | "success": true, |
| 90 | "success-count": 0 |
| 91 | } |
nothing calls this directly
no test coverage detected