ConditionKeyMap.RemoveKey() is called and the result is validated.
(t *testing.T)
| 84 | |
| 85 | // ConditionKeyMap.RemoveKey() is called and the result is validated. |
| 86 | func 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. |
| 113 | func TestCopyConditionKeyMap(t *testing.T) { |
nothing calls this directly
no test coverage detected