question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EachLike should allow a minimum of 0

See original GitHub issue

The EachLike matching helper has a keyword argument minimum that defaults to 1 and can not be lower than 1. However, many of our APIs return empty object arrays. Would it be possible to support a minimum=0 setting? Or some other flag that indicates the array can be empty?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jameshalsallcommented, Apr 29, 2021

Yeah, you can 😃 at least this is valid for me in the Go SDK

eachLike(map[string]interface{}{
	"foo":  "buzz",
	"bar": 10,
}, 0)

Having reflected, my comment yesterday is a bit silly, because Pact will obviously only validate the content of the attribute if it is specified, so it is not reliable. Also having read this article it makes more sense.

0reactions
mefellowscommented, Apr 30, 2021

Haha

If it makes you feel any better: https://github.com/pact-foundation/pact-support/pull/11

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Pact.eachLike() when array contents vary for each item
So is there a was to allow unexpected key/values in arrays because ... { "match": "type" } We're wondering if Pact NPM should...
Read more >
Matching | Pact Docs
Behaves like the eachLike matcher, but also applies a minimum and maximum length validation on the length of the array. The optional count ......
Read more >
Pact with Java (by example) - HMH Engineering
eachLike we can be asserting against multiple items coming back from the api. 5 — Array as starting point. All the examples we...
Read more >
question on array matching in pact-jvm - Google Groups
"min" : 0 } } }. Obviously, the extra [ ] around the body are a problem. But the matchers also don't look...
Read more >
i tried using valueBoolean MinType true 0 but 0 is not allow | Pact ...
for the same reason as above, we can't have a min of 0. If in all of the tests an empty array was...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found