mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-18 05:18:24 +02:00
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.
This commit is contained in:
parent
c93c1079cc
commit
b6fd507145
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user