mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
add sed test
Removes straightForwardTest that has not a clear scope since it test all that it is tested in the other tests. Adds sed test. Removes duplicated sed assertions.
This commit is contained in:
parent
69d0050e0c
commit
4360636609
@ -30,6 +30,7 @@ public class MTABuildTest extends BasePipelineTest {
|
|||||||
|
|
||||||
|
|
||||||
def currentDir
|
def currentDir
|
||||||
|
def mtaYaml
|
||||||
|
|
||||||
def mtaBuildScript
|
def mtaBuildScript
|
||||||
def cpe
|
def cpe
|
||||||
@ -38,6 +39,8 @@ public class MTABuildTest extends BasePipelineTest {
|
|||||||
void init() {
|
void init() {
|
||||||
|
|
||||||
currentDir = tmp.newFolder().toURI().getPath()[0..-2] //omit final '/'
|
currentDir = tmp.newFolder().toURI().getPath()[0..-2] //omit final '/'
|
||||||
|
mtaYaml = new File("${currentDir}/mta.yaml")
|
||||||
|
mtaYaml << defaultMtaYaml()
|
||||||
|
|
||||||
helper.registerAllowedMethod('readYaml', [Map], {
|
helper.registerAllowedMethod('readYaml', [Map], {
|
||||||
m ->
|
m ->
|
||||||
@ -55,8 +58,6 @@ public class MTABuildTest extends BasePipelineTest {
|
|||||||
@Test
|
@Test
|
||||||
public void environmentPathTest(){
|
public void environmentPathTest(){
|
||||||
|
|
||||||
new File("${currentDir}/mta.yaml") << defaultMtaYaml()
|
|
||||||
|
|
||||||
mtaBuildScript.call(buildTarget: 'NEO')
|
mtaBuildScript.call(buildTarget: 'NEO')
|
||||||
|
|
||||||
assert jscr.shell[1].contains('PATH=./node_modules/.bin:/usr/bin')
|
assert jscr.shell[1].contains('PATH=./node_modules/.bin:/usr/bin')
|
||||||
@ -64,9 +65,7 @@ public class MTABuildTest extends BasePipelineTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void straightForwardTest(){
|
public void sedTest(){
|
||||||
|
|
||||||
new File("${currentDir}/mta.yaml") << defaultMtaYaml()
|
|
||||||
|
|
||||||
mtaBuildScript.call(buildTarget: 'NEO')
|
mtaBuildScript.call(buildTarget: 'NEO')
|
||||||
|
|
||||||
@ -77,15 +76,11 @@ public class MTABuildTest extends BasePipelineTest {
|
|||||||
@Test
|
@Test
|
||||||
public void mtarFilePathFromCommonPipelineEnviromentTest(){
|
public void mtarFilePathFromCommonPipelineEnviromentTest(){
|
||||||
|
|
||||||
new File("${currentDir}/mta.yaml") << defaultMtaYaml()
|
|
||||||
|
|
||||||
mtaBuildScript.call(script: [commonPipelineEnvironment: cpe],
|
mtaBuildScript.call(script: [commonPipelineEnvironment: cpe],
|
||||||
buildTarget: 'NEO')
|
buildTarget: 'NEO')
|
||||||
|
|
||||||
def mtarFilePath = cpe.getMtarFilePath()
|
def mtarFilePath = cpe.getMtarFilePath()
|
||||||
|
|
||||||
assert jscr.shell[0] =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" ".*\/mta.yaml"$/
|
|
||||||
|
|
||||||
assert mtarFilePath == "${currentDir}/com.mycompany.northwind.mtar"
|
assert mtarFilePath == "${currentDir}/com.mycompany.northwind.mtar"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,12 +107,8 @@ public class MTABuildTest extends BasePipelineTest {
|
|||||||
@Test
|
@Test
|
||||||
void mtaJarLocationNotSetTest() {
|
void mtaJarLocationNotSetTest() {
|
||||||
|
|
||||||
new File("${currentDir}/mta.yaml") << defaultMtaYaml()
|
|
||||||
|
|
||||||
mtaBuildScript.call(buildTarget: 'NEO')
|
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 mta.jar --mtar ')
|
assert jscr.shell[1].contains(' -jar mta.jar --mtar ')
|
||||||
|
|
||||||
assert jlr.log.contains('[mtaBuild] Using MTA JAR from current working directory.')
|
assert jlr.log.contains('[mtaBuild] Using MTA JAR from current working directory.')
|
||||||
@ -127,12 +118,8 @@ public class MTABuildTest extends BasePipelineTest {
|
|||||||
@Test
|
@Test
|
||||||
void mtaJarLocationAsParameterTest() {
|
void mtaJarLocationAsParameterTest() {
|
||||||
|
|
||||||
new File("${currentDir}/mta.yaml") << defaultMtaYaml()
|
|
||||||
|
|
||||||
mtaBuildScript.call(mtaJarLocation: '/mylocation/mta', buildTarget: 'NEO')
|
mtaBuildScript.call(mtaJarLocation: '/mylocation/mta', 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 /mylocation/mta/mta.jar --mtar ')
|
assert jscr.shell[1].contains(' -jar /mylocation/mta/mta.jar --mtar ')
|
||||||
|
|
||||||
assert jlr.log.contains('[mtaBuild] MTA JAR "/mylocation/mta/mta.jar" retrieved from parameters.')
|
assert jlr.log.contains('[mtaBuild] MTA JAR "/mylocation/mta/mta.jar" retrieved from parameters.')
|
||||||
@ -141,6 +128,8 @@ public class MTABuildTest extends BasePipelineTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void noMtaPresentTest(){
|
public void noMtaPresentTest(){
|
||||||
|
|
||||||
|
mtaYaml.delete()
|
||||||
thrown.expect(FileNotFoundException)
|
thrown.expect(FileNotFoundException)
|
||||||
|
|
||||||
mtaBuildScript.call(buildTarget: 'NEO')
|
mtaBuildScript.call(buildTarget: 'NEO')
|
||||||
@ -152,7 +141,7 @@ public class MTABuildTest extends BasePipelineTest {
|
|||||||
thrown.expect(ParserException)
|
thrown.expect(ParserException)
|
||||||
thrown.expectMessage('while parsing a block mapping')
|
thrown.expectMessage('while parsing a block mapping')
|
||||||
|
|
||||||
new File("${currentDir}/mta.yaml") << badMtaYaml()
|
mtaYaml.text = badMtaYaml()
|
||||||
|
|
||||||
mtaBuildScript.call(buildTarget: 'NEO')
|
mtaBuildScript.call(buildTarget: 'NEO')
|
||||||
}
|
}
|
||||||
@ -163,7 +152,7 @@ public class MTABuildTest extends BasePipelineTest {
|
|||||||
thrown.expect(AbortException)
|
thrown.expect(AbortException)
|
||||||
thrown.expectMessage("Property 'ID' not found in mta.yaml file at: '")
|
thrown.expectMessage("Property 'ID' not found in mta.yaml file at: '")
|
||||||
|
|
||||||
new File("${currentDir}/mta.yaml") << noIdMtaYaml()
|
mtaYaml.text = noIdMtaYaml()
|
||||||
|
|
||||||
mtaBuildScript.call(buildTarget: 'NEO')
|
mtaBuildScript.call(buildTarget: 'NEO')
|
||||||
}
|
}
|
||||||
@ -174,8 +163,6 @@ public class MTABuildTest extends BasePipelineTest {
|
|||||||
thrown.expect(Exception)
|
thrown.expect(Exception)
|
||||||
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR buildTarget')
|
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR buildTarget')
|
||||||
|
|
||||||
new File("${currentDir}/mta.yaml") << defaultMtaYaml()
|
|
||||||
|
|
||||||
mtaBuildScript.call()
|
mtaBuildScript.call()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,8 +173,6 @@ public class MTABuildTest extends BasePipelineTest {
|
|||||||
binding.setVariable('env', [:])
|
binding.setVariable('env', [:])
|
||||||
binding.getVariable('env')['MTA_JAR_LOCATION'] = '/env/mta'
|
binding.getVariable('env')['MTA_JAR_LOCATION'] = '/env/mta'
|
||||||
|
|
||||||
new File("${currentDir}/mta.yaml") << defaultMtaYaml()
|
|
||||||
|
|
||||||
mtaBuildScript.call(buildTarget: 'NEO')
|
mtaBuildScript.call(buildTarget: 'NEO')
|
||||||
|
|
||||||
assert jscr.shell[1].contains('-jar /env/mta/mta.jar --mtar')
|
assert jscr.shell[1].contains('-jar /env/mta/mta.jar --mtar')
|
||||||
|
Loading…
Reference in New Issue
Block a user