Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response body is []. This is with "newJsonArrayMinLike(0, ...)" #108

Open
sergtk opened this issue Apr 26, 2024 · 3 comments
Open

Response body is []. This is with "newJsonArrayMinLike(0, ...)" #108

sergtk opened this issue Apr 26, 2024 · 3 comments

Comments

@sergtk
Copy link

sergtk commented Apr 26, 2024

When I specify newJsonArrayMinLike(0,...) in Java (zero min elements), then response body in pact-file is empty array "[]".
How such body is interpreted?
Provider test passed even with the body, which should not be matched.

How is body "[]" interpreted? It seems that body is considered as absent, because it seems considered as "the body contents are not important" according to the spec 3.
But I want to be sure, specification does not describe this, or this is a bug is in pact-jvm-consumer-java8.

This is when working with pact-jvm-consumer-java8, v4.0.6

Could somebody please clarify this?
Thanks.

@rholshausen
Copy link
Contributor

rholshausen commented May 3, 2024

Firstly, pact-jvm-consumer-java8 is very old and no longer supported. It has been replaced with au.com.dius.pact:consumer.

How is body "[]" interpreted?

It is an empty JSON array.

When I specify newJsonArrayMinLike(0,...)

This is stating that any number of items are acceptable in the array, including none. Thus the Provider test will pass with any number of items in the array.

@sergtk
Copy link
Author

sergtk commented May 3, 2024

It is an empty JSON array

Is empty JSON array is considered just like "empty JSON"?
"empty JSON" is stated in the pact spec, but it is not clear conserning "empty JSON array" if it is considered as "empty JSON" or not.

This is stating that any number of items are acceptable in the array, including none. Thus the Provider test will pass with any number of items in the array.

The problem is that elements of array which are not matched to the rules, just ignored. And provider tests passed, while provider tests should faild because of wrong data.
Anyway, this is already more about specific implementation of pact, not about pact spec.
Thanks.

@rholshausen
Copy link
Contributor

An empty JSON array is not "empty JSON", it contains two characters [].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants