ContainsKey succeeds if object contains given key. Example: object := NewObject(t, map[string]interface{}{"foo": 123}) object.ContainsKey("foo")
(key string)
| 996 | // object := NewObject(t, map[string]interface{}{"foo": 123}) |
| 997 | // object.ContainsKey("foo") |
| 998 | func (o *Object) ContainsKey(key string) *Object { |
| 999 | opChain := o.chain.enter("ContainsKey()") |
| 1000 | defer opChain.leave() |
| 1001 | |
| 1002 | if opChain.failed() { |
| 1003 | return o |
| 1004 | } |
| 1005 | |
| 1006 | if !containsKey(opChain, o.value, key) { |
| 1007 | opChain.fail(AssertionFailure{ |
| 1008 | Type: AssertContainsKey, |
| 1009 | Actual: &AssertionValue{o.value}, |
| 1010 | Expected: &AssertionValue{key}, |
| 1011 | Errors: []error{ |
| 1012 | errors.New("expected: map contains key"), |
| 1013 | }, |
| 1014 | }) |
| 1015 | } |
| 1016 | |
| 1017 | return o |
| 1018 | } |
| 1019 | |
| 1020 | // NotContainsKey succeeds if object doesn't contain given key. |
| 1021 | // |