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

Function TestComparisonWarnRule

internal/evaluator/evaluator_comparison_test.go:226–255  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

224}
225
226func TestComparisonWarnRule(t *testing.T) {
227 policyContent := `package main
228
229import rego.v1
230
231# METADATA
232# title: Always warn
233# custom:
234# short_name: always_warn
235warn contains result if {
236 result := {
237 "code": "main.always_warn",
238 "msg": "This is a warning",
239 }
240}
241`
242 pair := setupEvaluatorPair(t, policyContent, ecc.Source{})
243 ctx := context.Background()
244 inputPath := writeInput(t, map[string]any{"test": "value"})
245
246 target := EvaluationTarget{Inputs: []string{inputPath}, Target: "image:latest"}
247
248 cr, err := pair.conftest.Evaluate(ctx, target)
249 require.NoError(t, err)
250 or, err := pair.opa.Evaluate(ctx, target)
251 require.NoError(t, err)
252
253 assertSameOutcomes(t, "always-warn", cr, or)
254 assert.Contains(t, summarizeOutcomes(cr).warningCodes, "main.always_warn")
255}
256
257func TestComparisonMixedDenyAndWarn(t *testing.T) {
258 policyContent := `package main

Callers

nothing calls this directly

Calls 5

setupEvaluatorPairFunction · 0.85
writeInputFunction · 0.85
assertSameOutcomesFunction · 0.85
summarizeOutcomesFunction · 0.85
EvaluateMethod · 0.65

Tested by

no test coverage detected