ConditionKeyMap.Add() is called and the result is validated.
(t *testing.T)
| 26 | |
| 27 | // ConditionKeyMap.Add() is called and the result is validated. |
| 28 | func 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. |
| 56 | func TestConditionKeyMapRemove(t *testing.T) { |
nothing calls this directly
no test coverage detected