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

Function TestConditionKeyMapRemove

pkg/policy/bucket-policy-condition_test.go:56–83  ·  pkg/policy/bucket-policy-condition_test.go::TestConditionKeyMapRemove

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

(t *testing.T)

Source from the content-addressed store, hash-verified

54
55// ConditionKeyMap.Remove() is called and the result is validated.
56func TestConditionKeyMapRemove(t *testing.T) {
57 condKeyMap := make(ConditionKeyMap)
58 condKeyMap.Add("s3:prefix", set.CreateStringSet("hello", "world"))
59
60 testCases := []struct {
61 key string
62 value set.StringSet
63 expectedResult string
64 }{
65 // Remove non-existent key and value.
66 {"s3:myprefix", set.CreateStringSet("hello"), `{"s3:prefix":["hello","world"]}`},
67 // Remove existing key and value.
68 {"s3:prefix", set.CreateStringSet("hello"), `{"s3:prefix":["world"]}`},
69 // Remove existing key to make the key also removed.
70 {"s3:prefix", set.CreateStringSet("world"), `{}`},
71 }
72
73 for _, testCase := range testCases {
74 condKeyMap.Remove(testCase.key, testCase.value)
75 if data, err := json.Marshal(condKeyMap); err != nil {
76 t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err)
77 } else {
78 if string(data) != testCase.expectedResult {
79 t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
80 }
81 }
82 }
83}
84
85// ConditionKeyMap.RemoveKey() is called and the result is validated.
86func TestConditionKeyMapRemoveKey(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