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

Function TestConditionKeyMapAdd

pkg/policy/bucket-policy-condition_test.go:28–53  ·  pkg/policy/bucket-policy-condition_test.go::TestConditionKeyMapAdd

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

(t *testing.T)

Source from the content-addressed store, hash-verified

26
27// ConditionKeyMap.Add() is called and the result is validated.
28func TestConditionKeyMapAdd(t *testing.T) {
29 condKeyMap := make(ConditionKeyMap)
30 testCases := []struct {
31 key string
32 value set.StringSet
33 expectedResult string
34 }{
35 // Add new key and value.
36 {"s3:prefix", set.CreateStringSet("hello"), `{"s3:prefix":["hello"]}`},
37 // Add existing key and value.
38 {"s3:prefix", set.CreateStringSet("hello"), `{"s3:prefix":["hello"]}`},
39 // Add existing key and not value.
40 {"s3:prefix", set.CreateStringSet("world"), `{"s3:prefix":["hello","world"]}`},
41 }
42
43 for _, testCase := range testCases {
44 condKeyMap.Add(testCase.key, testCase.value)
45 if data, err := json.Marshal(condKeyMap); err != nil {
46 t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err)
47 } else {
48 if string(data) != testCase.expectedResult {
49 t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
50 }
51 }
52 }
53}
54
55// ConditionKeyMap.Remove() is called and the result is validated.
56func TestConditionKeyMapRemove(t *testing.T) {

Callers

nothing calls this directly

Calls 3

CreateStringSetFunction · 0.92
MarshalMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected