MCPcopy
hub / github.com/minio/minio-go / TestConditionMapRemove

Function TestConditionMapRemove

pkg/policy/bucket-policy-condition_test.go:218–244  ·  view source on GitHub ↗

ConditionMap.Remove() is called and the result is validated.

(t *testing.T)

Source from the content-addressed store, hash-verified

216
217// ConditionMap.Remove() is called and the result is validated.
218func TestConditionMapRemove(t *testing.T) {
219 condMap := make(ConditionMap)
220 condKeyMap := make(ConditionKeyMap)
221 condKeyMap.Add("s3:prefix", set.CreateStringSet("hello", "world"))
222 condMap.Add("StringEquals", condKeyMap)
223
224 testCases := []struct {
225 key string
226 expectedResult string
227 }{
228 // Remove non-existent key.
229 {"StringNotEquals", `{"StringEquals":{"s3:prefix":["hello","world"]}}`},
230 // Remove existing key.
231 {"StringEquals", `{}`},
232 }
233
234 for _, testCase := range testCases {
235 condMap.Remove(testCase.key)
236 if data, err := json.Marshal(condMap); err != nil {
237 t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err)
238 } else {
239 if string(data) != testCase.expectedResult {
240 t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
241 }
242 }
243 }
244}
245
246// mergeConditionMap() is called and the result is validated.
247func TestMergeConditionMap(t *testing.T) {

Callers

nothing calls this directly

Calls 4

CreateStringSetFunction · 0.92
MarshalMethod · 0.65
AddMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected