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

Function Test_ReportYaml

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

Source from the content-addressed store, hash-verified

122}
123
124func 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(`
135ec-version: development
136effective-time: "%s"
137filepaths:
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
161policy:
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
173success: 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

Callers

nothing calls this directly

Calls 5

toFormatMethod · 0.95
testInputsForFunction · 0.85
createTestPolicyFunction · 0.70
NewReportFunction · 0.70
EffectiveTimeMethod · 0.65

Tested by

no test coverage detected