MCPcopy Index your code
hub / github.com/gavv/httpexpect / Array

Method Array

value.go:263–285  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

261// value := NewValue(t, []interface{}{"foo", 123})
262// value.Array().ConsistsOf("foo", 123)
263func (v *Value) Array() *Array {
264 opChain := v.chain.enter("Array()")
265 defer opChain.leave()
266
267 if opChain.failed() {
268 return newArray(opChain, nil)
269 }
270
271 data, ok := v.value.([]interface{})
272
273 if !ok {
274 opChain.fail(AssertionFailure{
275 Type: AssertValid,
276 Actual: &AssertionValue{v.value},
277 Errors: []error{
278 errors.New("expected: value is array"),
279 },
280 })
281 return newArray(opChain, nil)
282 }
283
284 return newArray(opChain, data)
285}
286
287// String returns a new String attached to underlying value.
288//

Callers 15

TestValue_GetArrayFunction · 0.95
TestExpect_TraverseFunction · 0.45
TestExpect_BranchesFunction · 0.45
TestValue_FailedChainFunction · 0.45
TestValue_GettersFunction · 0.45
TestValue_PathTypesFunction · 0.45
TestFailureTemplateFunction · 0.45
TestSuccessTemplateFunction · 0.45
TestIrisThingsFunction · 0.45
TestIrisRedirectFunction · 0.45
TestFruitsFunction · 0.45

Calls 5

newArrayFunction · 0.85
enterMethod · 0.80
leaveMethod · 0.80
failedMethod · 0.80
failMethod · 0.80

Tested by 15

TestValue_GetArrayFunction · 0.76
TestExpect_TraverseFunction · 0.36
TestExpect_BranchesFunction · 0.36
TestValue_FailedChainFunction · 0.36
TestValue_GettersFunction · 0.36
TestValue_PathTypesFunction · 0.36
TestFailureTemplateFunction · 0.36
TestSuccessTemplateFunction · 0.36
TestIrisThingsFunction · 0.36
TestIrisRedirectFunction · 0.36
TestFruitsFunction · 0.36