1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00

Add tests asserting log messages

This commit is contained in:
Marcus Holl 2018-07-04 11:56:53 +02:00
parent 0d5e49e9d4
commit 20612c726f

View File

@ -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'")
}
}