Skip to content

Commit

Permalink
fix defect where stateChangeUrl is automatically set by overridden ur…
Browse files Browse the repository at this point in the history
…l function #101
  • Loading branch information
Ronald Holshausen committed Mar 29, 2015
1 parent 3065910 commit 55eb028
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class ConsumerInfo {
boolean stateChangeUsesBody = true

def url(String path) {
stateChange = new URL(path)
new URL(path)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,57 @@ class PactPluginTest {
assert consumers.find { it.name == 'Foo Consumer'}
assert consumers.find { it.name == 'Bar Consumer'}
}

@Test
public void 'configures the providers and consumers correctly'() {
def pactFileUrl = 'http://localhost:8000/pacts/provider/prividera/consumer/consumera/latest'
def stateChangeUrl = 'http://localhost:8080/stateChange'
project.pact {
serviceProviders {
ProviderA { providerInfo ->
startProviderTask = 'jettyEclipseRun'
terminateProviderTask = 'jettyEclipseStop'

port = 1234

hasPactWith('ConsumerA') {
pactFile = url(pactFileUrl)
stateChange = url(stateChangeUrl)
}
}
}
}

project.evaluate()

def provider = project.tasks.pactVerify_ProviderA.providerToVerify
assert provider.startProviderTask == 'jettyEclipseRun'
assert provider.terminateProviderTask == 'jettyEclipseStop'
assert provider.port == 1234

def consumer = provider.consumers.first()
assert consumer.name == 'ConsumerA'
assert consumer.pactFile == new URL(pactFileUrl)
assert consumer.stateChange == new URL(stateChangeUrl)
}

@Test
public void 'do not set the state change url automatically'() {
def pactFileUrl = 'http://localhost:8000/pacts/provider/prividera/consumer/consumera/latest'
project.pact {
serviceProviders {
ProviderA { providerInfo ->
hasPactWith('ConsumerA') {
pactFile = url(pactFileUrl)
}
}
}
}

project.evaluate()

def consumer = project.tasks.pactVerify_ProviderA.providerToVerify.consumers.first()
assert consumer.pactFile == new URL(pactFileUrl)
assert consumer.stateChange == null
}
}

0 comments on commit 55eb028

Please sign in to comment.