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

Function TestKeepSomeMetadataSingle

internal/output/output_test.go:1045–1108  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1043}
1044
1045func TestKeepSomeMetadataSingle(t *testing.T) {
1046 cases := []struct {
1047 name string
1048 input evaluator.Result
1049 expectedMetadata map[string]interface{}
1050 }{
1051 {
1052 name: "preserves required metadata excluding pipeline_intention",
1053 input: evaluator.Result{
1054 Message: "Test message",
1055 Metadata: map[string]interface{}{
1056 "code": "test.rule",
1057 "effective_on": "2023-01-01",
1058 "term": "test-term",
1059 "pipeline_intention": []string{"release", "production"},
1060 "title": "Test Rule Title",
1061 "description": "Test Rule Description",
1062 "some_other_key": "should be removed",
1063 },
1064 },
1065 expectedMetadata: map[string]interface{}{
1066 "code": "test.rule",
1067 "effective_on": "2023-01-01",
1068 "term": "test-term",
1069 },
1070 },
1071 {
1072 name: "preserves basic metadata without pipeline_intention",
1073 input: evaluator.Result{
1074 Message: "Test message",
1075 Metadata: map[string]interface{}{
1076 "code": "test.rule",
1077 "effective_on": "2023-01-01",
1078 "title": "Test Rule Title",
1079 "description": "Test Rule Description",
1080 "some_other_key": "should be removed",
1081 },
1082 },
1083 expectedMetadata: map[string]interface{}{
1084 "code": "test.rule",
1085 "effective_on": "2023-01-01",
1086 },
1087 },
1088 }
1089
1090 for _, tc := range cases {
1091 t.Run(tc.name, func(t *testing.T) {
1092 // Make a copy to avoid modifying the original
1093 result := evaluator.Result{
1094 Message: tc.input.Message,
1095 Metadata: make(map[string]interface{}),
1096 }
1097 for k, v := range tc.input.Metadata {
1098 result.Metadata[k] = v
1099 }
1100
1101 // Apply the function
1102 keepSomeMetadataSingle(result)

Callers

nothing calls this directly

Calls 2

keepSomeMetadataSingleFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected