1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-03 15:02:35 +02:00

Added Unit-Test for extensions using an older API

This commit is contained in:
Stephan Aßmus 2020-01-20 15:50:22 +01:00
parent 88a2600d2d
commit f59d9f9d49
2 changed files with 36 additions and 1 deletions

View File

@ -115,5 +115,33 @@ class PiperStageWrapperTest extends BasePiperTest {
assertThat(loggingRule.log, containsString('Config: ['))
assertThat(loggingRule.log, containsString('testBranch'))
}
}
@Test
void testStageOldInterceptor() {
helper.registerAllowedMethod('fileExists', [String.class], { path ->
return (path == '.pipeline/extensions/test_old_extension.groovy')
})
helper.registerAllowedMethod('load', [String.class], {
return helper.loadScript('test/resources/stages/test_old_extension.groovy')
})
nullScript.commonPipelineEnvironment.gitBranch = 'testBranch'
def executed = false
stepRule.step.piperStageWrapper(
script: nullScript,
juStabUtils: utils,
ordinal: 10,
stageName: 'test_old_extension'
) {
executed = true
}
assertThat(executed, is(true))
assertThat(loggingRule.log, containsString('[piperStageWrapper] Running project interceptor \'.pipeline/extensions/test_old_extension.groovy\' for test_old_extension.'))
assertThat(loggingRule.log, containsString('[Warning] The interface to implement extensions has changed.'))
assertThat(loggingRule.log, containsString('Stage Name: test_old_extension'))
assertThat(loggingRule.log, containsString('Config: ['))
assertThat(loggingRule.log, containsString('testBranch'))
}
}

View File

@ -0,0 +1,7 @@
void call(Closure originalStage, String stageName, Map configuration, Map params) {
echo "Stage Name: $stageName"
echo "Config: $configuration"
originalStage()
echo "Branch: ${params.script.commonPipelineEnvironment.gitBranch}"
}
return this