pact-js icon indicating copy to clipboard operation
pact-js copied to clipboard

<PactfileWriteMode> value not being recognized in <MessageConsumerOptions>

Open basickarl opened this issue 5 years ago • 5 comments

    "@pact-foundation/pact": "9.8.0",
    "@pact-foundation/pact-node": "10.4.0",

node 12.14

Code:

    return new MessageConsumerPact(<MessageConsumerOptions>{
        consumer,
        dir,
        pactfileWriteMode: <PactfileWriteMode>'overwrite',
        provider
    });

Log:

[2020-03-09T12:01:18.816Z]  INFO: [email protected]/794 on karl-Dell-Precision-M3800: Verifying message
[2020-03-09T12:01:18.817Z]  INFO: [email protected]/794 on karl-Dell-Precision-M3800: Creating Message
[2020-03-09T12:01:18.817Z]  INFO: [email protected]/794 on karl-Dell-Precision-M3800: Creating message pact
[2020-03-09T12:01:19.304Z]  INFO: [email protected]/794 on karl-Dell-Precision-M3800: 
    Could not find command "overwrite".

Code:

    return new MessageConsumerPact(<MessageConsumerOptions>{
        consumer,
        dir,
        pactfileWriteMode: <PactfileWriteMode>'merge',
        provider
    });

Log:

[2020-03-09T12:01:53.845Z]  INFO: [email protected]/978 on karl-Dell-Precision-M3800: Verifying message
[2020-03-09T12:01:53.846Z]  INFO: [email protected]/978 on karl-Dell-Precision-M3800: Creating Message
[2020-03-09T12:01:53.846Z]  INFO: [email protected]/978 on karl-Dell-Precision-M3800: Creating message pact
[2020-03-09T12:01:54.325Z]  INFO: [email protected]/978 on karl-Dell-Precision-M3800: 
    Could not find command "merge".

"overwrite" and "merge" result in no pact files being written.

When using "update", it just gives an empty log, but the pact files are written:

[2020-03-09T12:02:25.509Z]  INFO: [email protected]/1209 on karl-Dell-Precision-M3800: Verifying message
[2020-03-09T12:02:25.510Z]  INFO: [email protected]/1209 on karl-Dell-Precision-M3800: Creating Message
[2020-03-09T12:02:25.510Z]  INFO: [email protected]/1209 on karl-Dell-Precision-M3800: Creating message pact
[2020-03-09T12:02:26.136Z]  INFO: [email protected]/1209 on karl-Dell-Precision-M3800: 

As far as I can see <PactfileWriteMode> is used in two places, <MessageConsumerOptions> and in <MessageProviderOptions>. It doesn't seem to work in the first case though.

How we are currently doing is that before we run consumer tests we remove all the previous pact files and generate new files. Then we publish them to the broker. After that we run the provider tests which verify against the broker pact files published.

basickarl avatar Mar 09 '20 13:03 basickarl

Thanks I'll take a look today.

Are you running Windows or Linux btw? That might help us track it down

mefellows avatar Mar 09 '20 20:03 mefellows

Ah @mefellows Linux of course, I guess that would be important for you to follow!

basickarl avatar Mar 10 '20 08:03 basickarl

I think this is an issue with the type interface - it should just support update, and therefore needn't be an option.

TODO: mark the field as deprecated and do nothing, remove in next major.

mefellows avatar Apr 20 '20 11:04 mefellows

There is a valid use case for not having this as 'update'. If someone has split their tests over multiple files and are running them in parallel, multiple mock services may be started for the same pact, and the interactions from each need to be merged together. It's not a common use case, but I know there are some people out there doing it, because I remember the discussions.

bethesque avatar Apr 21 '20 22:04 bethesque

Yes, the current issue is that the JS interface thinks it behaves like the HTTP one, but it doesn't and is misleading.

We can mark as a feature request and create an issue in the Ruby project. Sound good?

mefellows avatar Apr 21 '20 22:04 mefellows