ConditionKeyMap.Remove() is called and the result is validated.
(t *testing.T)
| 54 | |
| 55 | // ConditionKeyMap.Remove() is called and the result is validated. |
| 56 | func TestConditionKeyMapRemove(t *testing.T) { |
| 57 | condKeyMap := make(ConditionKeyMap) |
| 58 | condKeyMap.Add("s3:prefix", set.CreateStringSet("hello", "world")) |
| 59 | |
| 60 | testCases := []struct { |
| 61 | key string |
| 62 | value set.StringSet |
| 63 | expectedResult string |
| 64 | }{ |
| 65 | // Remove non-existent key and value. |
| 66 | {"s3:myprefix", set.CreateStringSet("hello"), `{"s3:prefix":["hello","world"]}`}, |
| 67 | // Remove existing key and value. |
| 68 | {"s3:prefix", set.CreateStringSet("hello"), `{"s3:prefix":["world"]}`}, |
| 69 | // Remove existing key to make the key also removed. |
| 70 | {"s3:prefix", set.CreateStringSet("world"), `{}`}, |
| 71 | } |
| 72 | |
| 73 | for _, testCase := range testCases { |
| 74 | condKeyMap.Remove(testCase.key, testCase.value) |
| 75 | if data, err := json.Marshal(condKeyMap); err != nil { |
| 76 | t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err) |
| 77 | } else { |
| 78 | if string(data) != testCase.expectedResult { |
| 79 | t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data)) |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | // ConditionKeyMap.RemoveKey() is called and the result is validated. |
| 86 | func TestConditionKeyMapRemoveKey(t *testing.T) { |
nothing calls this directly
no test coverage detected