From b6fd507145bfba230c4a9d690e62a8eb34ead0f3 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 31 Aug 2018 15:41:31 +0200 Subject: [PATCH] Be more precise with libraryResource and read yaml in prepareDefaultValuesTest In the free wild it is the duty of libraryResource to provide some resource as text and it is the duty of readYaml to parse a text (... would also be possible to read a file instead just parsing text, but that is a different story). In our setup we just forwarded the resource name in libraryResource and reacted on that resource name inside read yaml. There was no yaml parsing at all, the yaml 'as it' was returned. The approach now is much closer to reality. Library resource now provides the text 'behind' the resource and yaml parses it. There is now a real yaml parsing. Read yaml is now not registered explicitly anymore. It is just the readYaml closure which is registerd by default for our tests. --- test/groovy/PrepareDefaultValuesTest.groovy | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/test/groovy/PrepareDefaultValuesTest.groovy b/test/groovy/PrepareDefaultValuesTest.groovy index 0ae67d65e..8160d5382 100644 --- a/test/groovy/PrepareDefaultValuesTest.groovy +++ b/test/groovy/PrepareDefaultValuesTest.groovy @@ -28,16 +28,14 @@ public class PrepareDefaultValuesTest extends BasePiperTest { @Before public void setup() { - helper.registerAllowedMethod("libraryResource", [String], { fileName-> return fileName }) - helper.registerAllowedMethod("readYaml", [Map], { m -> - switch(m.text) { - case 'default_pipeline_environment.yml': return [default: 'config'] - case 'custom.yml': return [custom: 'myConfig'] + helper.registerAllowedMethod("libraryResource", [String], { fileName -> + switch(fileName) { + case 'default_pipeline_environment.yml': return "default: 'config'" + case 'custom.yml': return "custom: 'myConfig'" case 'not_found': throw new hudson.AbortException('No such library resource not_found could be found') - default: return [the:'end'] + default: return "the:'end'" } }) - } @Test