(t *testing.T)
| 122 | } |
| 123 | |
| 124 | func Test_ReportYaml(t *testing.T) { |
| 125 | filePaths := []string{"/path/to/file1.yaml", "/path/to/file2.yaml", "/path/to/file3.yaml"} |
| 126 | inputs := testInputsFor(filePaths) |
| 127 | ctx := context.Background() |
| 128 | testPolicy := createTestPolicy(t, ctx) |
| 129 | report, err := NewReport(inputs, testPolicy, nil, false, true, true) |
| 130 | assert.NoError(t, err) |
| 131 | |
| 132 | testEffectiveTime := testPolicy.EffectiveTime().UTC().Format(time.RFC3339Nano) |
| 133 | |
| 134 | expected := fmt.Sprintf(` |
| 135 | ec-version: development |
| 136 | effective-time: "%s" |
| 137 | filepaths: |
| 138 | - filepath: /path/to/file1.yaml |
| 139 | success: false |
| 140 | success-count: 0 |
| 141 | successes: |
| 142 | - msg: success1 |
| 143 | violations: |
| 144 | - msg: violation1 |
| 145 | warnings: |
| 146 | - msg: warning1 |
| 147 | - filepath: /path/to/file2.yaml |
| 148 | success: false |
| 149 | success-count: 0 |
| 150 | successes: null |
| 151 | violations: |
| 152 | - msg: violation2 |
| 153 | warnings: null |
| 154 | - filepath: /path/to/file3.yaml |
| 155 | success: true |
| 156 | success-count: 0 |
| 157 | successes: |
| 158 | - msg: success3 |
| 159 | violations: null |
| 160 | warnings: null |
| 161 | policy: |
| 162 | description: Stuff and things |
| 163 | name: Default |
| 164 | sources: |
| 165 | - config: |
| 166 | include: |
| 167 | - basic |
| 168 | data: |
| 169 | - github.com/org/repo//data |
| 170 | name: Default |
| 171 | policy: |
| 172 | - github.com/org/repo//policy |
| 173 | success: false |
| 174 | `, testEffectiveTime) |
| 175 | |
| 176 | reportYaml, err := report.toFormat(YAML) |
| 177 | assert.NoError(t, err) |
| 178 | assert.YAMLEq(t, expected, string(reportYaml)) |
| 179 | assert.False(t, report.Success) |
| 180 | } |
| 181 |
nothing calls this directly
no test coverage detected