Skip to content

Commit

Permalink
fix: previous provider states must not be copied over to new interact…
Browse files Browse the repository at this point in the history
…ions #497
  • Loading branch information
Ronald Holshausen committed Jul 31, 2021
1 parent 08c639e commit 43ec874
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.xml.transform.TransformerException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -89,7 +90,7 @@ public class PactDslRequestWithPath extends PactDslRequestBase {
this.consumerPactBuilder = consumerPactBuilder;
this.consumer = existing.consumer;
this.provider = existing.provider;
this.state = existing.state;
this.state = new ArrayList<>();
this.description = description;
this.defaultResponseValues = defaultResponseValues;
this.path = existing.path;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package au.com.dius.pact.consumer

import au.com.dius.pact.core.model.ProviderState
import spock.lang.Issue
import spock.lang.Specification

class ConsumerPactBuilderSpec extends Specification {
@Issue('#497')
def 'previous provider states must not be copied over to new interactions'() {
given:
def pact = ConsumerPactBuilder.consumer('test')
.hasPactWith('provider')
.given('greeting', [name: 'world'])
.uponReceiving('GET /hello')
.path('/hello')
.method('POST')
.willRespondWith()
.status(200)
.uponReceiving('GET /hello-user')
.path('/hello-user')
.method('POST')
.willRespondWith()
.status(200)
.toPact()

expect:
pact.interactions[0].providerStates == [new ProviderState('greeting', [name: 'world'])]
pact.interactions[1].providerStates == []
}
}

0 comments on commit 43ec874

Please sign in to comment.