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

Matching rule on array size gets inherited by all child arrays #396

Closed
artamonovkirill opened this issue Mar 27, 2017 · 2 comments
Closed
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@artamonovkirill
Copy link
Contributor

artamonovkirill commented Mar 27, 2017

Following pact:

def provider = new PactBuilder()
provider {
    serviceConsumer 'Consumer'
    hasPactWith 'Provider'
    port 9000

    uponReceiving('request')
    withAttributes(
        method: 'get',
        path: PATH)
    willRespondWith(
        status: 200)
    withBody {
        parent minLike(2, 2) {
            child(['a'])
        }
    }
}

will generate a matching rule like:

{
	"body": {
		"$.parent": {
			"matchers": [{
				"match": "type",
				"min": 2
			}]
		}
	}
}

that will fail on a provider response like:

{
	"parent": [{
		"child": ["a"]
	}, {
		"child": ["a"]
	}]
}

with

java.lang.AssertionError: 
0 - $.parent.0.child -> {mismatch=Expected List(a) to have minimum 2, diff=}

Consumer & provider test code: https://github.com/artamonovkirill/pact-issues-examples/tree/master/src/test/groovy/com/github/artamonovkirill/pact/minlike

@uglyog uglyog added the bug Indicates an unexpected problem or unintended behavior label Sep 9, 2017
@uglyog
Copy link
Member

uglyog commented Aug 22, 2021

This has been fixed in 4.1.25

@uglyog uglyog closed this as completed Aug 22, 2021
@artamonovkirill
Copy link
Contributor Author

Thanks 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants