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

Function TestParsePolicyDiffFromMessage

cmd/validate/vsa_test.go:1724–1844  ·  view source on GitHub ↗

TestParsePolicyDiffFromMessage tests the parsePolicyDiffFromMessage helper function

(t *testing.T)

Source from the content-addressed store, hash-verified

1722
1723// TestParsePolicyDiffFromMessage tests the parsePolicyDiffFromMessage helper function
1724func TestParsePolicyDiffFromMessage(t *testing.T) {
1725 tests := []struct {
1726 name string
1727 result *vsa.ValidationResult
1728 expectedAdded int
1729 expectedRemoved int
1730 expectedChanged int
1731 expectedHasDiff bool
1732 }{
1733 {
1734 name: "structured PolicyDiff field (preferred)",
1735 result: &vsa.ValidationResult{
1736 ReasonCode: "policy_mismatch",
1737 PolicyDiff: &vsa.PolicyDiff{
1738 Added: 1,
1739 Removed: 0,
1740 Changed: 0,
1741 },
1742 Message: "❌ Policy mismatch detected — 1 added, 0 removed, 0 changed; 1 differences",
1743 },
1744 expectedAdded: 1,
1745 expectedRemoved: 0,
1746 expectedChanged: 0,
1747 expectedHasDiff: true,
1748 },
1749 {
1750 name: "structured PolicyDiff with all changes",
1751 result: &vsa.ValidationResult{
1752 ReasonCode: "policy_mismatch",
1753 PolicyDiff: &vsa.PolicyDiff{
1754 Added: 2,
1755 Removed: 3,
1756 Changed: 1,
1757 },
1758 Message: "Policy mismatch - 2 added, 3 removed, 1 changed",
1759 },
1760 expectedAdded: 2,
1761 expectedRemoved: 3,
1762 expectedChanged: 1,
1763 expectedHasDiff: true,
1764 },
1765 {
1766 name: "fallback to message parsing with em dash",
1767 result: &vsa.ValidationResult{
1768 Message: "❌ Policy mismatch detected — 1 added, 0 removed, 0 changed; 1 differences",
1769 },
1770 expectedAdded: 1,
1771 expectedRemoved: 0,
1772 expectedChanged: 0,
1773 expectedHasDiff: true,
1774 },
1775 {
1776 name: "fallback to message parsing with regular dash",
1777 result: &vsa.ValidationResult{
1778 Message: "Policy mismatch - 2 added, 3 removed, 1 changed",
1779 },
1780 expectedAdded: 2,
1781 expectedRemoved: 3,

Callers

nothing calls this directly

Calls 2

RunMethod · 0.65

Tested by

no test coverage detected