-
-
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: write empty bodies to the Pact file #1611
- Loading branch information
1 parent
870a999
commit fc7e13e
Showing
9 changed files
with
118 additions
and
25 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
13 changes: 13 additions & 0 deletions
13
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,13 @@ | ||
package au.com.dius.pact.core.model | ||
|
||
import spock.lang.Issue | ||
import spock.lang.Specification | ||
|
||
class HttpRequestSpec extends Specification { | ||
@Issue('#1611') | ||
def 'supports empty bodies'() { | ||
expect: | ||
new HttpRequest('GET', '/', [:], [:], OptionalBody.empty()).toMap() == | ||
[method: 'GET', path: '/', body: [content: '']] | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
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,12 @@ | ||
package au.com.dius.pact.core.model | ||
|
||
import spock.lang.Issue | ||
import spock.lang.Specification | ||
|
||
class HttpResponseSpec extends Specification { | ||
@Issue('#1611') | ||
def 'supports empty bodies'() { | ||
expect: | ||
new HttpResponse(200, [:], OptionalBody.empty()).toMap() == [status: 200, body: [content: '']] | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
core/model/src/test/groovy/au/com/dius/pact/core/model/V4PactKtSpec.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,21 @@ | ||
package au.com.dius.pact.core.model | ||
|
||
import au.com.dius.pact.core.support.json.JsonValue | ||
import spock.lang.Specification | ||
|
||
import static au.com.dius.pact.core.model.V4PactKt.bodyFromJson | ||
|
||
class V4PactKtSpec extends Specification { | ||
def 'bodyFromJson - when body is empty in the Pact file'() { | ||
expect: | ||
bodyFromJson('body', new JsonValue.Object(json), [:]) == body | ||
|
||
where: | ||
|
||
json | body | ||
[:] | OptionalBody.missing() | ||
[body: JsonValue.Null.INSTANCE] | OptionalBody.nullBody() | ||
[body: new JsonValue.StringValue('')] | OptionalBody.empty() | ||
[body: new JsonValue.Object([content: new JsonValue.StringValue('')])] | OptionalBody.empty() | ||
} | ||
} |