ConditionMap.Remove() is called and the result is validated.
(t *testing.T)
| 216 | |
| 217 | // ConditionMap.Remove() is called and the result is validated. |
| 218 | func TestConditionMapRemove(t *testing.T) { |
| 219 | condMap := make(ConditionMap) |
| 220 | condKeyMap := make(ConditionKeyMap) |
| 221 | condKeyMap.Add("s3:prefix", set.CreateStringSet("hello", "world")) |
| 222 | condMap.Add("StringEquals", condKeyMap) |
| 223 | |
| 224 | testCases := []struct { |
| 225 | key string |
| 226 | expectedResult string |
| 227 | }{ |
| 228 | // Remove non-existent key. |
| 229 | {"StringNotEquals", `{"StringEquals":{"s3:prefix":["hello","world"]}}`}, |
| 230 | // Remove existing key. |
| 231 | {"StringEquals", `{}`}, |
| 232 | } |
| 233 | |
| 234 | for _, testCase := range testCases { |
| 235 | condMap.Remove(testCase.key) |
| 236 | if data, err := json.Marshal(condMap); err != nil { |
| 237 | t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err) |
| 238 | } else { |
| 239 | if string(data) != testCase.expectedResult { |
| 240 | t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data)) |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | // mergeConditionMap() is called and the result is validated. |
| 247 | func TestMergeConditionMap(t *testing.T) { |
nothing calls this directly
no test coverage detected