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

Function TestConditionKeyMapRemoveKey

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

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

(t *testing.T)

Source from the content-addressed store, hash-verified

84
85// ConditionKeyMap.RemoveKey() is called and the result is validated.
86func TestConditionKeyMapRemoveKey(t *testing.T) {
87 condKeyMap := make(ConditionKeyMap)
88 condKeyMap.Add("s3:prefix", set.CreateStringSet("hello", "world"))
89
90 testCases := []struct {
91 key string
92 expectedResult string
93 }{
94 // Remove non-existent key.
95 {"s3:myprefix", `{"s3:prefix":["hello","world"]}`},
96 // Remove existing key.
97 {"s3:prefix", `{}`},
98 }
99
100 for _, testCase := range testCases {
101 condKeyMap.RemoveKey(testCase.key)
102 if data, err := json.Marshal(condKeyMap); err != nil {
103 t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err)
104 } else {
105 if string(data) != testCase.expectedResult {
106 t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
107 }
108 }
109 }
110}
111
112// CopyConditionKeyMap() is called and the result is validated.
113func TestCopyConditionKeyMap(t *testing.T) {

Callers

nothing calls this directly

Calls 4

CreateStringSetFunction · 0.92
RemoveKeyMethod · 0.80
MarshalMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected