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

Method Object

value.go:230–252  ·  view source on GitHub ↗

Object returns a new Object attached to underlying value. If underlying value is not an object (map[string]interface{}), failure is reported and empty (but non-nil) value is returned. Example: value := NewValue(t, map[string]interface{}{"foo": 123}) value.Object().ContainsKey("foo")

()

Source from the content-addressed store, hash-verified

228// value := NewValue(t, map[string]interface{}{"foo": 123})
229// value.Object().ContainsKey("foo")
230func (v *Value) Object() *Object {
231 opChain := v.chain.enter("Object()")
232 defer opChain.leave()
233
234 if opChain.failed() {
235 return newObject(opChain, nil)
236 }
237
238 data, ok := v.value.(map[string]interface{})
239
240 if !ok {
241 opChain.fail(AssertionFailure{
242 Type: AssertValid,
243 Actual: &AssertionValue{v.value},
244 Errors: []error{
245 errors.New("expected: value is object"),
246 },
247 })
248 return newObject(opChain, nil)
249 }
250
251 return newObject(opChain, data)
252}
253
254// Array returns a new Array attached to underlying value.
255//

Callers 15

TestValue_GetObjectFunction · 0.95
TestResponse_JSONFunction · 0.45
TestResponse_JSONPFunction · 0.45
TestExpect_TraverseFunction · 0.45
TestExpect_BranchesFunction · 0.45
TestExpect_InheritanceFunction · 0.45
TestValue_FailedChainFunction · 0.45
TestValue_GettersFunction · 0.45
TestWsHandlerJSONFunction · 0.45
TestWsFastHandlerJSONFunction · 0.45
TestIrisRedirectFunction · 0.45

Calls 5

newObjectFunction · 0.85
enterMethod · 0.80
leaveMethod · 0.80
failedMethod · 0.80
failMethod · 0.80

Tested by 15

TestValue_GetObjectFunction · 0.76
TestResponse_JSONFunction · 0.36
TestResponse_JSONPFunction · 0.36
TestExpect_TraverseFunction · 0.36
TestExpect_BranchesFunction · 0.36
TestExpect_InheritanceFunction · 0.36
TestValue_FailedChainFunction · 0.36
TestValue_GettersFunction · 0.36
TestWsHandlerJSONFunction · 0.36
TestWsFastHandlerJSONFunction · 0.36
TestIrisRedirectFunction · 0.36