1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00

add mtaJarLocation from environment test

Adds a test to check if the mtaJarLocation is read from the environment
and removes all duplicate assertions.
This commit is contained in:
Alejandra Ferreiro Vidal 2018-02-05 15:28:16 +01:00
parent 5d60bc8199
commit 868d13749c

View File

@ -46,7 +46,6 @@ public class MTABuildTest extends BasePipelineTest {
helper.registerAllowedMethod('pwd', [], { currentDir } )
binding.setVariable('PATH', '/usr/bin')
binding.setVariable('env', [:])
mtaBuildScript = loadScript("mtaBuild.groovy").mtaBuild
cpe = loadScript('commonPipelineEnvironment.groovy').commonPipelineEnvironment
@ -67,25 +66,17 @@ public class MTABuildTest extends BasePipelineTest {
@Test
public void straightForwardTest(){
binding.getVariable('env')['MTA_JAR_LOCATION'] = '/opt/mta'
new File("${currentDir}/mta.yaml") << defaultMtaYaml()
mtaBuildScript.call(buildTarget: 'NEO')
assert jscr.shell[0] =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" ".*\/mta.yaml"$/
assert jscr.shell[1].contains(' -jar /opt/mta/mta.jar --mtar ')
assert jlr.log.contains( "[mtaBuild] MTA JAR \"/opt/mta/mta.jar\" retrieved from environment.")
}
@Test
public void mtarFilePathFromCommonPipelineEnviromentTest(){
binding.getVariable('env')['MTA_JAR_LOCATION'] = '/opt/mta'
new File("${currentDir}/mta.yaml") << defaultMtaYaml()
mtaBuildScript.call(script: [commonPipelineEnvironment: cpe],
@ -95,19 +86,13 @@ public class MTABuildTest extends BasePipelineTest {
assert jscr.shell[0] =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" ".*\/mta.yaml"$/
assert jscr.shell[1].contains(' -jar /opt/mta/mta.jar --mtar ')
assert mtarFilePath == "${currentDir}/com.mycompany.northwind.mtar"
assert jlr.log.contains("[mtaBuild] MTA JAR \"/opt/mta/mta.jar\" retrieved from environment.")
}
@Test
public void mtaBuildWithSurroundingDirTest(){
binding.getVariable('env')['MTA_JAR_LOCATION'] = '/opt/mta'
def newDirName = 'newDir'
def newDirPath = "${currentDir}/${newDirName}"
def newDir = new File(newDirPath)
@ -121,11 +106,7 @@ public class MTABuildTest extends BasePipelineTest {
assert jscr.shell[0] =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" ".*\/newDir\/mta.yaml"$/
assert jscr.shell[1].contains(' -jar /opt/mta/mta.jar --mtar ')
assert mtarFilePath == "${currentDir}/${newDirName}/com.mycompany.northwind.mtar"
assert jlr.log.contains("[mtaBuild] MTA JAR \"/opt/mta/mta.jar\" retrieved from environment.")
}
@Test
@ -198,6 +179,22 @@ public class MTABuildTest extends BasePipelineTest {
mtaBuildScript.call()
}
@Test
void mtaJarLocationFromEnvironmentTest(){
binding.setVariable('env', [:])
binding.getVariable('env')['MTA_JAR_LOCATION'] = '/env/mta'
new File("${currentDir}/mta.yaml") << defaultMtaYaml()
mtaBuildScript.call(buildTarget: 'NEO')
assert jscr.shell[1].contains('-jar /env/mta/mta.jar --mtar')
assert jlr.log.contains('[mtaBuild] MTA JAR "/env/mta/mta.jar" retrieved from environment.')
}
private defaultMtaYaml(){
return '''
_schema-version: "2.0.0"