Skip to content

fix: server start and delete interactions order #47

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions pacttesting/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,16 @@ func TestWithStubServices(pactFilePaths []Pact, testFunc func()) error {
pacts := groupByProvider(readAllPacts(pactFilePaths))

for _, server := range pactServers {
EnsurePactRunning(server.Provider, server.Consumer)
err := server.DeleteInteractions()
if err != nil {
log.WithError(err).Errorf("Error deleting interactions")
log.WithError(err).Error("Error deleting interactions")
}
}

var err error
for _, p := range pacts {
key := p.Provider.Name + p.Consumer.Name
EnsurePactRunning(p.Provider.Name, p.Consumer.Name)

for _, i := range p.Interactions {
err = pactServers[key].AddInteraction(i)
if err != nil {
Expand Down Expand Up @@ -318,11 +317,11 @@ func EnsurePactRunning(provider, consumer string) string {
return mockServer.BaseURL
}

log.Infof("starting new mock server for consumer: %s, provider: %s", consumer, provider)
port := assignPort(provider, consumer)
log.Infof("starting new mock server for consumer: %s, provider: %s, host: %s:%d", consumer, provider, bind, port)
// This is done manually rather than using pact-go's service manager code, since that pipes the output streams,
// so isn't suitable for long-running pact-servers if there is a problem that triggers stdout/stderr output.
// It also prevents the servers from remaining started when run from goland or compiled test binaries
port := assignPort(provider, consumer)
args := []string{
"service",
"--pact-specification-version",
Expand Down