MCPcopy Create free account
hub / github.com/gavv/httpexpect / ContainsKey

Method ContainsKey

object.go:998–1018  ·  view source on GitHub ↗

ContainsKey succeeds if object contains given key. Example: object := NewObject(t, map[string]interface{}{"foo": 123}) object.ContainsKey("foo")

(key string)

Source from the content-addressed store, hash-verified

996// object := NewObject(t, map[string]interface{}{"foo": 123})
997// object.ContainsKey("foo")
998func (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//

Callers 6

TestExpect_TraverseFunction · 0.80
TestObject_FailedChainFunction · 0.80
TestObject_ContainsKeyFunction · 0.80
TestFruitsFunction · 0.80
TestE2EReport_PathFunction · 0.80
TestE2EReport_AliasFunction · 0.80

Calls 5

containsKeyFunction · 0.85
enterMethod · 0.80
leaveMethod · 0.80
failedMethod · 0.80
failMethod · 0.80

Tested by 6

TestExpect_TraverseFunction · 0.64
TestObject_FailedChainFunction · 0.64
TestObject_ContainsKeyFunction · 0.64
TestFruitsFunction · 0.64
TestE2EReport_PathFunction · 0.64
TestE2EReport_AliasFunction · 0.64