MCPcopy Create free account
hub / github.com/conforma/cli / Test_ReportText

Function Test_ReportText

internal/input/report_test.go:287–340  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

285}
286
287func Test_ReportText(t *testing.T) {
288 inputs := []Input{
289 {
290 FilePath: "/path/to/file1.yaml",
291 Violations: []evaluator.Result{
292 {
293 Message: "violation1",
294 Metadata: map[string]interface{}{
295 "code": "test.violation",
296 },
297 },
298 },
299 Warnings: []evaluator.Result{
300 {
301 Message: "warning1",
302 Metadata: map[string]interface{}{
303 "code": "test.warning",
304 },
305 },
306 },
307 Successes: []evaluator.Result{
308 {
309 Message: "success1",
310 Metadata: map[string]interface{}{
311 "code": "test.success",
312 },
313 },
314 },
315 SuccessCount: 1,
316 Success: false,
317 },
318 }
319 ctx := context.Background()
320 testPolicy := createTestPolicy(t, ctx)
321 report, err := NewReport(inputs, testPolicy, nil, false, true, true)
322 assert.NoError(t, err)
323
324 reportText, err := report.toFormat(Text)
325 assert.NoError(t, err)
326 textOutput := string(reportText)
327
328 // Verify basic structure
329 assert.Contains(t, textOutput, "Success: false")
330 assert.Contains(t, textOutput, "Result: FAILURE")
331 assert.Contains(t, textOutput, "Violations: 1")
332 assert.Contains(t, textOutput, "Warnings: 1")
333 assert.Contains(t, textOutput, "Successes: 1")
334 assert.Contains(t, textOutput, "Input File: /path/to/file1.yaml")
335 assert.Contains(t, textOutput, "Results:")
336 assert.Contains(t, textOutput, "[Violation] test.violation")
337 assert.Contains(t, textOutput, "[Warning] test.warning")
338 // Successes should not be shown when showSuccesses=false
339 assert.NotContains(t, textOutput, "[Success] test.success")
340}
341
342func Test_ReportText_ShowSuccesses(t *testing.T) {
343 inputs := []Input{

Callers

nothing calls this directly

Calls 3

toFormatMethod · 0.95
createTestPolicyFunction · 0.70
NewReportFunction · 0.70

Tested by

no test coverage detected