0

I'm new to Pact and I am trying to verify a pact on provider side using pact-python but some matching rules are getting ignored.

WARN: Ignoring unsupported matching rules {"$.num_issues"=>{"matchers"=>[{"match"=>"integer"}], "combine"=>"AND"}, "$.error"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.response[0].issue_id"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.response[0].msg"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.response[0].similar_fix_found"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.response[1].issue_id"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.response[1].msg"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.response[1].similar_fix_found"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}} for path ['body']

Consumer is Java based API and Provider is a Python based API.

                    "body": {
                        "$.num_issues": {
                            "matchers": [
                                {
                                    "match": "integer"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.error": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.response[0].issue_id": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.response[0].msg": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.response[0].similar_fix_found": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.response[1].issue_id": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.response[1].msg": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.response[1].similar_fix_found": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        }
                    }
                }
            }
        }
    ],
    "metadata": {
        "pact-specification": {
            "version": "3.0.0"
        }
    }

Changing the pact-specification version to 2.0.0 by hand also didn't work as required.

Can anyone suggest something..?

Sarthak
  • 5
  • 1

1 Answers1

0

You need to explicitly set the specification version in the Java consumer test.

For example, in a JUnit test you can do it like so:

@PactTestFor(providerName = "pactflow-example-provider-java-kafka", providerType = ProviderType.ASYNCH, pactVersion = PactSpecVersion.V2)

The matchers and structure of the pact file differs based on the version, so just changing the version in the pact after won't help.

Matthew Fellows
  • 3,669
  • 1
  • 15
  • 18
  • Unfortunetly, this does not work because PactSpecVersion.V2 does not support message/async – naveen Nov 16 '21 at 11:56
  • I'm not sure what you mean naveen. If you need it to support message/async then it must be at least v3 yes, and the languages that produce/verify it must also support v3. If you have a different problem I'd suggest creating a new question – Matthew Fellows Nov 17 '21 at 12:04
  • What I meant was `providerType = ProviderType.ASYNCH, pactVersion = PactSpecVersion.V2` are conflicting setting. You can't have ProviderType.ASYNCH and PactSpecVersion.V2, it doesn't work. For ProviderType.ASYNCH to work you need you need PactSpecVersion.V3. – naveen Nov 17 '21 at 13:14
  • Yes you can't do that. I think you have a different situation to this so I'd recommend asking a new question that can be answered on here – Matthew Fellows Nov 18 '21 at 21:10