-
-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: PactBuilder was not correctly setting up HTTP interaction given …
…a Map structure
- Loading branch information
Showing
7 changed files
with
247 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
core/model/src/test/groovy/au/com/dius/pact/core/model/HttpRequestSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package au.com.dius.pact.core.model | ||
|
||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
class HttpRequestSpec extends Specification { | ||
def 'allows configuring the interaction from properties'() { | ||
given: | ||
def interaction = new HttpRequest() | ||
|
||
when: | ||
interaction.updateProperties([ | ||
'method': 'PUT', | ||
'path': '/reports/report002.csv', | ||
'query': [a: 'b'], | ||
'headers': ['x-a': 'b'] | ||
]) | ||
|
||
then: | ||
interaction.method == 'PUT' | ||
interaction.path == '/reports/report002.csv' | ||
interaction.headers == ['x-a': ['b']] | ||
interaction.query == [a: ['b']] | ||
} | ||
|
||
@Unroll | ||
def 'supports setting up the query parameters'() { | ||
given: | ||
def interaction = new HttpRequest() | ||
|
||
when: | ||
interaction.updateProperties([query: queryValue]) | ||
|
||
then: | ||
interaction.query == query | ||
|
||
where: | ||
|
||
queryValue | query | ||
[a: ['b']] | [a: ['b']] | ||
[a: 'b'] | [a: ['b']] | ||
'a=b' | [a: ['b']] | ||
} | ||
|
||
@Unroll | ||
def 'supports setting up the headers'() { | ||
given: | ||
def interaction = new HttpRequest() | ||
|
||
when: | ||
interaction.updateProperties([headers: headerValue]) | ||
|
||
then: | ||
interaction.headers == headers | ||
|
||
where: | ||
|
||
headerValue | headers | ||
[a: ['b']] | [a: ['b']] | ||
[a: 'b'] | [a: ['b']] | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
core/model/src/test/groovy/au/com/dius/pact/core/model/HttpResponseSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package au.com.dius.pact.core.model | ||
|
||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
class HttpResponseSpec extends Specification { | ||
def 'allows configuring the interaction from properties'() { | ||
given: | ||
def interaction = new HttpResponse() | ||
|
||
when: | ||
interaction.updateProperties([ | ||
'status': '201', | ||
'headers': ['x-a': 'b'] | ||
]) | ||
|
||
then: | ||
interaction.status == 201 | ||
interaction.headers == ['x-a': ['b']] | ||
} | ||
|
||
@Unroll | ||
def 'supports setting up the status'() { | ||
given: | ||
def interaction = new HttpResponse() | ||
|
||
when: | ||
interaction.updateProperties([status: statusValue]) | ||
|
||
then: | ||
interaction.status == status | ||
|
||
where: | ||
|
||
statusValue | status | ||
204 | 204 | ||
'203' | 203 | ||
} | ||
|
||
@Unroll | ||
def 'supports setting up the headers'() { | ||
given: | ||
def interaction = new HttpResponse() | ||
|
||
when: | ||
interaction.updateProperties([headers: headerValue]) | ||
|
||
then: | ||
interaction.headers == headers | ||
|
||
where: | ||
|
||
headerValue | headers | ||
[a: ['b']] | [a: ['b']] | ||
[a: 'b'] | [a: ['b']] | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
core/model/src/test/groovy/au/com/dius/pact/core/model/SynchronousHttpSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package au.com.dius.pact.core.model | ||
|
||
import spock.lang.Specification | ||
|
||
class SynchronousHttpSpec extends Specification { | ||
def 'allows configuring the interaction from properties'() { | ||
given: | ||
def interaction = new V4Interaction.SynchronousHttp('', 'test') | ||
|
||
when: | ||
interaction.updateProperties([ | ||
'request.method': 'PUT', | ||
'request.path': '/reports/report002.csv', | ||
'request.query': [a: 'b'], | ||
'request.headers': ['x-a': 'b'], | ||
'response.status': '205', | ||
'response.headers': ['x-b': ['b']] | ||
]) | ||
|
||
then: | ||
interaction.request.method == 'PUT' | ||
interaction.request.path == '/reports/report002.csv' | ||
interaction.request.headers == ['x-a': ['b']] | ||
interaction.request.query == [a: ['b']] | ||
interaction.response.status == 205 | ||
interaction.response.headers == ['x-b': ['b']] | ||
} | ||
} |