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:
parent
88a2600d2d
commit
f59d9f9d49
@ -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'))
|
||||
}
|
||||
}
|
||||
|
7
test/resources/stages/test_old_extension.groovy
Normal file
7
test/resources/stages/test_old_extension.groovy
Normal 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
|
Loading…
x
Reference in New Issue
Block a user