mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-18 05:18:24 +02:00
wip
This commit is contained in:
parent
7ce0c85fe9
commit
c29fb02dd9
35
test/groovy/PrepareDefaultValuesTest.groovy
Normal file
35
test/groovy/PrepareDefaultValuesTest.groovy
Normal file
@ -0,0 +1,35 @@
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test
|
||||
import org.junit.rules.RuleChain;
|
||||
|
||||
import com.sap.piper.DefaultValueCache
|
||||
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsStepRule;
|
||||
import util.Rules
|
||||
|
||||
public class PrepareDefaultValuesTest extends BasePiperTest {
|
||||
|
||||
private JenkinsStepRule jsr = new JenkinsStepRule(this)
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules
|
||||
.getCommonRules(this)
|
||||
.around(jsr)
|
||||
|
||||
@Test
|
||||
public void testMerge() {
|
||||
|
||||
helper.registerAllowedMethod("libraryResource", [String], { fileName-> return fileName })
|
||||
helper.registerAllowedMethod("readYaml", [Map], { m ->
|
||||
switch(m.text) {
|
||||
case 'default_pipeline_environment.yml': return [a: 'x']
|
||||
default: return [the:'end']
|
||||
}
|
||||
})
|
||||
jsr.step.call(script: nullScript)
|
||||
|
||||
|
||||
println DefaultValueCache.getInstance().getDefaultValues()
|
||||
}
|
||||
}
|
@ -19,8 +19,8 @@ def call(Map parameters = [:]) {
|
||||
for (def configFileName : configurationFiles){
|
||||
def configuration = readYaml text: libraryResource(configFileName)
|
||||
defaultValues = MapUtils.merge(
|
||||
MapUtils.pruneNull(defaultValues),
|
||||
MapUtils.pruneNull(configuration))
|
||||
MapUtils.pruneNulls(defaultValues),
|
||||
MapUtils.pruneNulls(configuration))
|
||||
}
|
||||
DefaultValueCache.createInstance(defaultValues)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user