From 20612c726ff73774dd948870aa73248a54d2cbee Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Wed, 4 Jul 2018 11:56:53 +0200 Subject: [PATCH] Add tests asserting log messages --- test/groovy/PrepareDefaultValuesTest.groovy | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/groovy/PrepareDefaultValuesTest.groovy b/test/groovy/PrepareDefaultValuesTest.groovy index 367d06868..0ae67d65e 100644 --- a/test/groovy/PrepareDefaultValuesTest.groovy +++ b/test/groovy/PrepareDefaultValuesTest.groovy @@ -7,12 +7,15 @@ import org.junit.rules.RuleChain; import com.sap.piper.DefaultValueCache import util.BasePiperTest +import util.JenkinsLoggingRule +import util.JenkinsShellCallRule import util.JenkinsStepRule; import util.Rules public class PrepareDefaultValuesTest extends BasePiperTest { private JenkinsStepRule jsr = new JenkinsStepRule(this) + private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this) private ExpectedException thrown = ExpectedException.none() @Rule @@ -20,6 +23,7 @@ public class PrepareDefaultValuesTest extends BasePiperTest { .getCommonRules(this) .around(thrown) .around(jsr) + .around(jlr) @Before public void setup() { @@ -98,4 +102,21 @@ public class PrepareDefaultValuesTest extends BasePiperTest { assert DefaultValueCache.getInstance().getDefaultValues().default == 'config' assert DefaultValueCache.getInstance().getDefaultValues().custom == 'myConfig' } + + @Test + public void testAssertNoLogMessageInCaseOfNoAdditionalConfigFiles() { + + jsr.step.call(script: nullScript) + + assert ! jlr.log.contains("Loading configuration file 'default_pipeline_environment.yml'") + } + + @Test + public void testAssertLogMessageInCaseOfMoreThanOneConfigFile() { + + jsr.step.call(script: nullScript, customDefaults: ['custom.yml']) + + assert jlr.log.contains("Loading configuration file 'default_pipeline_environment.yml'") + assert jlr.log.contains("Loading configuration file 'custom.yml'") + } }