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

Difference in matching rules for headers/query (Pact DSL vs. Groovy DSL) #1346

Closed
tlinkowski opened this issue Apr 19, 2021 · 3 comments
Closed

Comments

@tlinkowski
Copy link

tlinkowski commented Apr 19, 2021

Hi, as an example, imagine a boolean query parameter (or header - it's the same issue) named debugMode.

Definition

Pact DSL:

.matchQuery("debugMode", "true|false", "true")

Groovy DSL:

                .withAttributes([
                        ...
                        query  : [
                                debugMode: bool(true)
                        ]
                ])

Generated Pact "request"

Both DSLs:

        "query": {
          "debugMode": [
            "true"
          ]
        },

Generated Pact "matching rules"

Pact DSL:

            "debugMode": {
              "matchers": [
                {
                  "match": "regex",
                  "regex": "true|false"
                }
              ],
              "combine": "AND"
            }

Groovy DSL:

          "query": {
            "debugMode": {
              "matchers": [
                {
                  "match": "type"
                }
              ],
              "combine": "AND"
            }

Question

Is the behavior in Groovy DSL correct?

Will the "type" matcher actually allow only "true" or "false"? I'm wondering since the example in Pact "request" is actually a String, not a Boolean (and there seems to be no trace in the Pact that debugMode is of Boolean type).

@uglyog
Copy link
Member

uglyog commented May 1, 2021

I think you are correct, the bool function just adds a type matcher, which will match any strings. Let me confirm.

@uglyog
Copy link
Member

uglyog commented May 1, 2021

I've added a boolean matcher that will match the string values of true and false. Will only work with V4 spec, but you can also use the regex matcher.

@uglyog
Copy link
Member

uglyog commented May 9, 2021

4.2.5 has been released

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