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

Function TestFormatPolicyDifferences

internal/validate/vsa/validator_test.go:156–195  ·  view source on GitHub ↗

TestFormatPolicyDifferences tests the FormatPolicyDifferences function

(t *testing.T)

Source from the content-addressed store, hash-verified

154
155// TestFormatPolicyDifferences tests the FormatPolicyDifferences function
156func TestFormatPolicyDifferences(t *testing.T) {
157 tests := []struct {
158 name string
159 differences []equivalence.PolicyDifference
160 expectOutput string
161 }{
162 {
163 name: "empty differences",
164 differences: []equivalence.PolicyDifference{},
165 expectOutput: "VSA policy does not match supplied policy (no specific differences identified)",
166 },
167 {
168 name: "single difference",
169 differences: []equivalence.PolicyDifference{
170 {
171 Kind: equivalence.DiffAdded,
172 Path: equivalence.FieldPath{"test", "path"},
173 Summary: "test message",
174 },
175 },
176 expectOutput: "❌ Policy mismatch detected — 1 added, 0 removed, 0 changed; 1 differences",
177 },
178 {
179 name: "multiple differences",
180 differences: []equivalence.PolicyDifference{
181 {Kind: equivalence.DiffAdded, Path: equivalence.FieldPath{"test", "added"}, Summary: "added"},
182 {Kind: equivalence.DiffRemoved, Path: equivalence.FieldPath{"test", "removed"}, Summary: "removed"},
183 {Kind: equivalence.DiffChanged, Path: equivalence.FieldPath{"test", "changed"}, Summary: "changed"},
184 },
185 expectOutput: "❌ Policy mismatch detected — 1 added, 1 removed, 1 changed; 3 differences",
186 },
187 }
188
189 for _, tt := range tests {
190 t.Run(tt.name, func(t *testing.T) {
191 result := FormatPolicyDifferences(tt.differences)
192 assert.Contains(t, result, tt.expectOutput)
193 })
194 }
195}
196
197// TestExtractPolicyFromVSA_EdgeCases tests edge cases for ExtractPolicyFromVSA
198func TestExtractPolicyFromVSA_EdgeCases(t *testing.T) {

Callers

nothing calls this directly

Calls 2

FormatPolicyDifferencesFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected