mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
8a019f5b86
read yaml rule is a very frequently used rule. But having the rule in the common rules means we cannot register text or files to that rule, which makes it less handy to work with yaml files in the tests.
73 lines
2.3 KiB
Groovy
73 lines
2.3 KiB
Groovy
import org.junit.Rule
|
|
import org.junit.Test
|
|
import org.junit.rules.RuleChain
|
|
import util.*
|
|
|
|
import static org.hamcrest.Matchers.containsString
|
|
import static org.junit.Assert.assertFalse
|
|
import static org.junit.Assert.assertThat
|
|
|
|
class PipelineStashFilesAfterBuildTest extends BasePiperTest {
|
|
JenkinsStepRule jsr = new JenkinsStepRule(this)
|
|
JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
|
JenkinsReadJsonRule jrj = new JenkinsReadJsonRule(this)
|
|
|
|
@Rule
|
|
public RuleChain rules = Rules
|
|
.getCommonRules(this)
|
|
.around(new JenkinsReadYamlRule(this))
|
|
.around(jrj)
|
|
.around(jlr)
|
|
.around(jsr)
|
|
|
|
@Test
|
|
void testStashAfterBuild() {
|
|
helper.registerAllowedMethod("fileExists", [String.class], {
|
|
searchTerm ->
|
|
return false
|
|
})
|
|
jsr.step.call(
|
|
script: nullScript,
|
|
juStabUtils: utils
|
|
)
|
|
// asserts
|
|
assertFalse(jlr.log.contains('Stash content: checkmarx'))
|
|
assertThat(jlr.log, containsString('Stash content: classFiles'))
|
|
assertThat(jlr.log, containsString('Stash content: sonar'))
|
|
}
|
|
|
|
@Test
|
|
void testStashAfterBuildWithCheckmarx() {
|
|
helper.registerAllowedMethod("fileExists", [String.class], {
|
|
searchTerm ->
|
|
return true
|
|
})
|
|
jsr.step.call(
|
|
script: nullScript,
|
|
juStabUtils: utils,
|
|
runCheckmarx: true
|
|
)
|
|
// asserts
|
|
assertThat(jlr.log, containsString('Stash content: checkmarx'))
|
|
assertThat(jlr.log, containsString('Stash content: classFiles'))
|
|
assertThat(jlr.log, containsString('Stash content: sonar'))
|
|
}
|
|
|
|
@Test
|
|
void testStashAfterBuildWithCheckmarxConfig() {
|
|
helper.registerAllowedMethod("fileExists", [String.class], {
|
|
searchTerm ->
|
|
return true
|
|
})
|
|
jsr.step.call(
|
|
script: [commonPipelineEnvironment: [configuration: [steps: [executeCheckmarxScan: [checkmarxProject: 'TestProject']]]]],
|
|
juStabUtils: utils,
|
|
)
|
|
// asserts
|
|
assertThat(jlr.log, containsString('Stash content: checkmarx'))
|
|
assertThat(jlr.log, containsString('Stash content: classFiles'))
|
|
assertThat(jlr.log, containsString('Stash content: sonar'))
|
|
}
|
|
|
|
}
|