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

Pact test ignores the date format and fails #1729

Closed
timon483 opened this issue Nov 20, 2023 · 1 comment
Closed

Pact test ignores the date format and fails #1729

timon483 opened this issue Nov 20, 2023 · 1 comment

Comments

@timon483
Copy link

timon483 commented Nov 20, 2023

Hello,

We have an issue that after migration some Pact tests fail. It seems that the test ignores the matching rule for the date in contract.

Matching rule:
"$.entity.month": {
"matchers": [
{
"match": "date",
"format": "yyyy-MM"
}
],

Maven dependency:

    <dependency>
        <groupId>au.com.dius.pact</groupId>
        <artifactId>consumer</artifactId>
        <version>4.1.24</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>au.com.dius.pact.consumer</groupId>
        <artifactId>java8</artifactId>
        <version>4.1.24</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>au.com.dius.pact.consumer</groupId>
        <artifactId>junit5</artifactId>
        <version>4.1.24</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>au.com.dius.pact.provider</groupId>
        <artifactId>junit5</artifactId>
        <version>4.1.24</version>
        <scope>test</scope>
    </dependency>

The tested event has a field in format "yyyy-mm". However, I get the following output:

1.1) body: $.entity.month Expected "2023-02" to match a date of 'yyyy-MM-dd': Unable to parse the date: 2023-02

It seems that the field "format" of matcher is just ignored and the test expects a date in standard format.

I have tried to change the version of pact provider and consumer. But it didn't help at all. Can it be a Java version issue?

Expected behaviour: the test is green.

Environment: Java 17, Kotlin

Please tell me if you need extra information! And thank you in advance.

@timon483
Copy link
Author

The issue was solved after I updated the dependency to 4.1.41

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

1 participant