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

Function TestCopyConditionKeyMap

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

CopyConditionKeyMap() is called and the result is validated.

(t *testing.T)

Source from the content-addressed store, hash-verified

111
112// CopyConditionKeyMap() is called and the result is validated.
113func TestCopyConditionKeyMap(t *testing.T) {
114 emptyCondKeyMap := make(ConditionKeyMap)
115 nonEmptyCondKeyMap := make(ConditionKeyMap)
116 nonEmptyCondKeyMap.Add("s3:prefix", set.CreateStringSet("hello", "world"))
117
118 testCases := []struct {
119 condKeyMap ConditionKeyMap
120 expectedResult string
121 }{
122 // To test empty ConditionKeyMap.
123 {emptyCondKeyMap, `{}`},
124 // To test non-empty ConditionKeyMap.
125 {nonEmptyCondKeyMap, `{"s3:prefix":["hello","world"]}`},
126 }
127
128 for _, testCase := range testCases {
129 condKeyMap := CopyConditionKeyMap(testCase.condKeyMap)
130 if data, err := json.Marshal(condKeyMap); err != nil {
131 t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err)
132 } else {
133 if string(data) != testCase.expectedResult {
134 t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
135 }
136 }
137 }
138}
139
140// mergeConditionKeyMap() is called and the result is validated.
141func TestMergeConditionKeyMap(t *testing.T) {

Callers

nothing calls this directly

Calls 4

CreateStringSetFunction · 0.92
CopyConditionKeyMapFunction · 0.85
MarshalMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected