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

Function Test_ValidateInputCmd_StrictMode

cmd/validate/input_test.go:185–212  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

183}
184
185func Test_ValidateInputCmd_StrictMode(t *testing.T) {
186 fs := afero.NewMemMapFs()
187 require.NoError(t, afero.WriteFile(fs, "/file.yaml", []byte("some: data"), 0o644))
188
189 // Mock validator: returns no error, but a violation.
190 outMock := &output.Output{
191 PolicyCheck: []evaluator.Outcome{
192 {
193 Failures: []evaluator.Result{
194 {Message: "Some violation"},
195 },
196 },
197 },
198 }
199
200 cmd, _ := setUpValidateInputCmd(mockValidate(outMock, nil), fs)
201 cmd.SetArgs([]string{
202 "input",
203 "--file", "/file.yaml",
204 "--policy", `{"publicKey": "testkey"}`,
205 "--strict", "true",
206 })
207
208 utils.SetTestRekorPublicKey(t)
209 err := cmd.Execute()
210 assert.Error(t, err)
211 assert.Contains(t, err.Error(), "success criteria not met")
212}
213
214func Test_ValidateInputCmd_NonStrictMode(t *testing.T) {
215 fs := afero.NewMemMapFs()

Callers

nothing calls this directly

Calls 4

SetTestRekorPublicKeyFunction · 0.92
setUpValidateInputCmdFunction · 0.85
mockValidateFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected