pact-foundation / pact-go

Golang version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
http://pact.io
MIT License
860 stars 109 forks source link

Configuration to automatically delete `pact` directory when re-running contract tests #173

Open dsinecos opened 3 years ago

dsinecos commented 3 years ago

Software versions

Expected behaviour

When running contract tests using go test, presently I need to either manually delete the pact directory or configure a Before hook to delete the pact directory. If I don't do this certain changes will not be overwritten when re-running the pact tests.

For eg. when I change the text inside matchers eg. pact.S("Original text") to pact.S("Changed text"). It doesn't get updated in the generated pact files. I need to delete the pact folder and rerun the tests for these changes to take effect.

Actual behaviour

Based on a conversation with Matt in slack ( Refer for conversation ) the functionality to automatically delete the pact directory exists in the shared core. The configuration will have to be exposed.

This configuration will automatically delete the pact directory on rerunning the contract tests.

Steps to reproduce

-

Relevent log files

-

mefellows commented 3 years ago

Thanks for this, I'll look at this on my next OSS day.

YOU54F commented 2 months ago

So I think the original defect

when I change the text inside matchers eg. pact.S("Original text") to pact.S("Changed text"). It doesn't get updated in the generated pact files.

is the same as listed in https://github.com/pact-foundation/pact-reference/issues/77

fixed by commit https://github.com/pact-foundation/pact-reference/commit/3acf4376bc475e0b1a2acaa08c2b1505ad36d4b4

I can't see anything in the shared core for deleting files prior to a test run

mefellows commented 2 months ago

Yeah it might be, I can't remember what I was thinking so far back. The core doesn't know when the testing starts or finishes - each interaction is effectively tested on its own (it gets its own mock server, for example). Probably any cleaning would need to happen in the client or by the user (current recommendation).