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

Function TestSet

internal/policy/cache/cache_test.go:111–158  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

109}
110
111func TestSet(t *testing.T) {
112 ctx := context.Background()
113
114 tests := []struct {
115 name string
116 key string
117 value string
118 expectedValue string
119 expectedFound bool
120 }{
121 {
122 name: "set new key-value pair",
123 key: "newkey",
124 value: "newvalue",
125 expectedValue: "newvalue",
126 expectedFound: true,
127 },
128 {
129 name: "set empty value",
130 key: "emptykey",
131 value: "",
132 expectedValue: "",
133 expectedFound: true,
134 },
135 {
136 name: "set empty key",
137 key: "",
138 value: "emptykeyvalue",
139 expectedValue: "emptykeyvalue",
140 expectedFound: true,
141 },
142 }
143
144 for _, tt := range tests {
145 t.Run(tt.name, func(t *testing.T) {
146 // Create a fresh cache for each test
147 testCache := NewPolicyCache(ctx)
148
149 // Execute test
150 testCache.Set(tt.key, tt.value, nil)
151
152 // Verify the value was set correctly
153 value, found := testCache.Get(tt.key)
154 assert.Equal(t, tt.expectedValue, value)
155 assert.Equal(t, tt.expectedFound, found)
156 })
157 }
158}
159
160func TestNewPolicyCache(t *testing.T) {
161 tests := []struct {

Callers

nothing calls this directly

Calls 4

SetMethod · 0.95
GetMethod · 0.95
NewPolicyCacheFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected