From 7f36ca0f7410c49406544feaa0582202f83ca529 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Mon, 13 Nov 2017 10:11:56 +0100 Subject: [PATCH] Use regex for asserting sed command instead of having two checks, one for the first part of the command and one for asserting the trailing file name at the end of the command. --- test/groovy/MTABuildTest.groovy | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/test/groovy/MTABuildTest.groovy b/test/groovy/MTABuildTest.groovy index 3d2ebcb16..abc0bc690 100644 --- a/test/groovy/MTABuildTest.groovy +++ b/test/groovy/MTABuildTest.groovy @@ -84,8 +84,7 @@ public class MTABuildTest extends BasePipelineTest { def script = loadScript(pipeline) def mtarFilePath = script.execute() - assert shellCalls[0].startsWith('sed -ie \"s/\\\${timestamp}/`date +%Y%m%d%H%M%S`/g\" ') - assert shellCalls[0].endsWith('/mta.yaml"') + assert shellCalls[0] =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" ".*\/mta.yaml"$/ assert shellCalls[1].contains("PATH=./node_modules/.bin:/usr/bin") @@ -108,8 +107,7 @@ public class MTABuildTest extends BasePipelineTest { def script = loadScript(pipeline) def mtarFilePath = script.execute() - assert shellCalls[0].startsWith('sed -ie \"s/\\\${timestamp}/`date +%Y%m%d%H%M%S`/g\" ') - assert shellCalls[0].endsWith('/mta.yaml"') + assert shellCalls[0] =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" ".*\/mta.yaml"$/ assert shellCalls[1].contains("PATH=./node_modules/.bin:/usr/bin") @@ -134,8 +132,7 @@ public class MTABuildTest extends BasePipelineTest { def script = loadScript(pipeline) def mtarFilePath = script.execute(newDirName) - assert shellCalls[0].startsWith('sed -ie \"s/\\\${timestamp}/`date +%Y%m%d%H%M%S`/g\" ') - assert shellCalls[0].endsWith('/mta.yaml"') + assert shellCalls[0] =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" ".*\/newDir\/mta.yaml"$/ assert shellCalls[1].contains("PATH=./node_modules/.bin:/usr/bin") @@ -155,8 +152,7 @@ public class MTABuildTest extends BasePipelineTest { def script = loadScript(pipeline) def mtarFilePath = script.execute() - assert shellCalls[0].startsWith('sed -ie \"s/\\\${timestamp}/`date +%Y%m%d%H%M%S`/g\" ') - assert shellCalls[0].endsWith('/mta.yaml"') + assert shellCalls[0] =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" ".*\/mta.yaml"$/ assert shellCalls[1].contains("PATH=./node_modules/.bin:/usr/bin") @@ -177,8 +173,7 @@ public class MTABuildTest extends BasePipelineTest { def script = loadScript(pipeline) def mtarFilePath = script.execute() - assert shellCalls[0].startsWith('sed -ie \"s/\\\${timestamp}/`date +%Y%m%d%H%M%S`/g\" ') - assert shellCalls[0].endsWith('/mta.yaml"') + assert shellCalls[0] =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" ".*\/mta.yaml"$/ assert shellCalls[1].contains("PATH=./node_modules/.bin:/usr/bin")