1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

add multiple versions verification tests

This commit is contained in:
Alejandra Ferreiro Vidal 2018-05-03 13:43:34 +02:00
parent bc6ce8b3ba
commit 53e5c0fe6b

View File

@ -156,6 +156,48 @@ class ToolDescriptorTest extends BasePipelineTest {
tool.verifyVersion(script, configuration)
}
@Test
void verifyToolVersion_WithMultipleVersionsTest() {
def neoVersions = ['neo-java-web': '3.39.10', 'neo-javaee6-wp': '2.132.6', 'neo-javaee7-wp': '1.21.13']
def tool = new ToolDescriptor('SAP Cloud Platform Console Client', 'NEO_HOME', 'neoHome', '/tools/', 'neo.sh', neoVersions, 'version')
helper.registerAllowedMethod('sh', [Map], { Map m -> getVersion(m) })
tool.verifyVersion(script, configuration)
assert jlr.log.contains("Verifying SAP Cloud Platform Console Client version 3.39.10 or compatible version.")
assert jlr.log.contains("Verification success. SAP Cloud Platform Console Client version 3.39.10 is installed.")
}
@Test
void verifyToolVersion_WithMultipleVersions_FailedTest() {
def neoVersions = ['neo-java-web': '3.39.10', 'neo-javaee6-wp': '2.132.6', 'neo-javaee7-wp': '1.21.13']
def tool = new ToolDescriptor('SAP Cloud Platform Console Client', 'NEO_HOME', 'neoHome', '/tools/', 'neo.sh', neoVersions, 'version')
thrown.expect(AbortException)
thrown.expectMessage("The verification of SAP Cloud Platform Console Client failed. Please check 'neo.sh'. script returned exit code 127.")
helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionFailed(m) })
tool.verifyVersion(script, configuration)
}
@Test
void verifyToolVersion_WithMultipleVersions_IncompatibleVersionTest() {
def neoVersions = ['neo-java-web': '3.39.10', 'neo-javaee6-wp': '2.132.6', 'neo-javaee7-wp': '1.21.13']
def tool = new ToolDescriptor('SAP Cloud Platform Console Client', 'NEO_HOME', 'neoHome', '/tools/', 'neo.sh', neoVersions, 'version')
thrown.expect(AbortException)
thrown.expectMessage("The installed version of SAP Cloud Platform Console Client is 1.0.5. Please install version 3.39.10 or a compatible version.")
helper.registerAllowedMethod('sh', [Map], { Map m -> getIncompatibleVersion(m) })
tool.verifyVersion(script, configuration)
}
private getEnvVars(Map m) {
@ -179,8 +221,10 @@ class ToolDescriptorTest extends BasePipelineTest {
private getVersion(Map m) {
if(m.script.contains('version')) {
return '3.39.10'
if(m.script.contains('neo.sh version')) {
return '''SAP Cloud Platform Console Client
SDK version : 3.39.10
Runtime : neo-java-web'''
} else {
return getNoEnvVars(m)
}
@ -188,7 +232,7 @@ class ToolDescriptorTest extends BasePipelineTest {
private getVersionFailed(Map m) {
if(m.script.contains('version')) {
if(m.script.contains('neo.sh version')) {
throw new AbortException('script returned exit code 127')
} else {
return getNoEnvVars(m)
@ -197,8 +241,10 @@ class ToolDescriptorTest extends BasePipelineTest {
private getIncompatibleVersion(Map m) {
if(m.script.contains('version')) {
return '1.0.5'
if(m.script.contains('neo.sh version')) {
return '''SAP Cloud Platform Console Client
SDK version : 1.0.5
Runtime : neo-java-web'''
} else {
return getNoEnvVars(m)
}