Fix request headers occurring after absent header not being added to generated test method. Fixes gh-1647 (#1663)
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user