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

Method ContainsValue

object.go:1055–1075  ·  view source on GitHub ↗

ContainsValue succeeds if object contains given value with any key. Before comparison, both object and value are converted to canonical form. Example: object := NewObject(t, map[string]interface{}{"foo": 123}) object.ContainsValue(123)

(value interface{})

Source from the content-addressed store, hash-verified

1053// object := NewObject(t, map[string]interface{}{"foo": 123})
1054// object.ContainsValue(123)
1055func (o *Object) ContainsValue(value interface{}) *Object {
1056 opChain := o.chain.enter("ContainsValue()")
1057 defer opChain.leave()
1058
1059 if opChain.failed() {
1060 return o
1061 }
1062
1063 if _, ok := containsValue(opChain, o.value, value); !ok {
1064 opChain.fail(AssertionFailure{
1065 Type: AssertContainsElement,
1066 Actual: &AssertionValue{o.value},
1067 Expected: &AssertionValue{value},
1068 Errors: []error{
1069 errors.New("expected: map contains element (with any key)"),
1070 },
1071 })
1072 }
1073
1074 return o
1075}
1076
1077// NotContainsValue succeeds if object does not contain given value with any key.
1078// Before comparison, both object and value are converted to canonical form.

Callers 3

TestObject_FailedChainFunction · 0.80
TestObject_ContainsValueFunction · 0.80
TestFruitsFunction · 0.80

Calls 5

containsValueFunction · 0.85
enterMethod · 0.80
leaveMethod · 0.80
failedMethod · 0.80
failMethod · 0.80

Tested by 3

TestObject_FailedChainFunction · 0.64
TestObject_ContainsValueFunction · 0.64
TestFruitsFunction · 0.64