Fix request headers occurring after absent header not being added to generated test method. Fixes gh-1647 (#1663)

This commit is contained in:
cselagea
2021-05-22 02:42:52 -06:00
committed by GitHub
parent bfb5e0240b
commit 2eea2152ca
2 changed files with 6 additions and 2 deletions

View File

@@ -44,7 +44,7 @@ class MockMvcHeadersGiven implements Given {
while (iterator.hasNext()) {
Header header = iterator.next();
if (ofAbsentType(header)) {
return;
continue;
}
if (iterator.hasNext()) {
bb.addLine(string(header));

View File

@@ -520,7 +520,7 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
}
}
@Issue('#424')
@Issue(['#424','#1647'])
def 'should not put an absent header to the request [#methodBuilderName]'() {
given:
Contract contractDsl = Contract.make {
@@ -528,7 +528,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
method 'GET'
url '/mytest'
headers {
header('header-before', anyNonBlankString())
header('myheader', absent())
header('header-after', anyNonBlankString())
}
}
response {
@@ -540,6 +542,8 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
String test = singleTestGenerator(contractDsl)
then:
!test.contains('myheader')
test.contains('header-before')
test.contains('header-after')
and:
SyntaxChecker.
tryToCompileWithoutCompileStatic(methodBuilderName, test)