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

Method Every

object.go:402–430  ·  view source on GitHub ↗

Every runs the passed function for all the key value pairs in the object. If assertion inside function fails, the original Object is marked failed. Every will execute the function for all values in the object irrespective of assertion failures for some values in the object. The function is invoke

(fn func(key string, value *Value))

Source from the content-addressed store, hash-verified

400// value.String().NotEmpty()
401// })
402func (o *Object) Every(fn func(key string, value *Value)) *Object {
403 opChain := o.chain.enter("Every()")
404 defer opChain.leave()
405
406 if opChain.failed() {
407 return o
408 }
409
410 if fn == nil {
411 opChain.fail(AssertionFailure{
412 Type: AssertUsage,
413 Errors: []error{
414 errors.New("unexpected nil function argument"),
415 },
416 })
417 return o
418 }
419
420 for _, kv := range o.sortedKV() {
421 func() {
422 valueChain := opChain.replace("Every[%q]", kv.key)
423 defer valueChain.leave()
424
425 fn(kv.key, newValue(valueChain, kv.val))
426 }()
427 }
428
429 return o
430}
431
432// Filter accepts a function that returns a boolean. The function is ran
433// over the object elements. If the function returns true, the element passes

Callers 1

TestObject_EveryFunction · 0.95

Calls 7

sortedKVMethod · 0.95
newValueFunction · 0.85
enterMethod · 0.80
leaveMethod · 0.80
failedMethod · 0.80
failMethod · 0.80
replaceMethod · 0.80

Tested by 1

TestObject_EveryFunction · 0.76