Skip to content

Commit b2517d2

Browse files
committed
chore: V4 response specification tests were not being run
1 parent 6054d6a commit b2517d2

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

core/model/src/main/kotlin/au/com/dius/pact/core/model/V4HttpParts.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ data class HttpResponse @JvmOverloads constructor(
235235
}
236236

237237
companion object {
238+
@JvmStatic
238239
fun fromJson(json: JsonValue): HttpResponse {
239240
val status = when {
240241
json.has("status") -> {

pact-specification-test/src/main/resources/v4/response/headers/header value is different case.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"comment": "Headers values are case sensitive",
44
"expected" : {
55
"headers": {
6-
"Accept": "alligators"
6+
"X-Accept": "alligators"
77
}
88
},
99
"actual": {
1010
"headers": {
11-
"Accept": "Alligators"
11+
"X-Accept": "Alligators"
1212
}
1313
}
1414
}

pact-specification-test/src/test/groovy/specification/BaseResponseSpec.groovy

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package specification
22

33
import au.com.dius.pact.core.model.DefaultPactReader
4+
import au.com.dius.pact.core.model.HttpResponse
45
import au.com.dius.pact.core.support.Json
56
import au.com.dius.pact.core.support.json.JsonParser
67
import groovy.util.logging.Slf4j
@@ -10,7 +11,7 @@ import spock.lang.Specification
1011
class BaseResponseSpec extends Specification {
1112

1213
static List loadTestCases(String testDir) {
13-
def resources = ResponseSpecificationV1Spec.getResource(testDir)
14+
def resources = BaseResponseSpec.getResource(testDir)
1415
def file = new File(resources.toURI())
1516
def result = []
1617
file.eachDir { d ->
@@ -31,4 +32,28 @@ class BaseResponseSpec extends Specification {
3132
result
3233
}
3334

35+
static List loadV4TestCases(String testDir) {
36+
def resources = BaseRequestSpec.getResource(testDir)
37+
def file = new File(resources.toURI())
38+
def result = []
39+
file.eachDir { d ->
40+
d.eachFile { f ->
41+
def json = f.withReader { JsonParser.INSTANCE.parseReader(it) }
42+
def jsonMap = Json.INSTANCE.toMap(json)
43+
def expected = HttpResponse.fromJson(json.asObject().get('expected'))
44+
def actual = HttpResponse.fromJson(json.asObject().get('actual'))
45+
result << [
46+
d.name,
47+
f.name,
48+
jsonMap.comment,
49+
jsonMap.match,
50+
jsonMap.match ? 'should match' : 'should not match',
51+
expected,
52+
actual
53+
]
54+
}
55+
}
56+
result
57+
}
58+
3459
}

0 commit comments

Comments
 (0)