mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +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.
60 lines
2.3 KiB
Groovy
60 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.*
|
|
|
|
class PipelineStashFilesBeforeBuildTest extends BasePiperTest {
|
|
JenkinsStepRule jsr = new JenkinsStepRule(this)
|
|
JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
|
JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
|
|
//JenkinsReadJsonRule jrj = new JenkinsReadJsonRule(this)
|
|
|
|
@Rule
|
|
public RuleChain rules = Rules
|
|
.getCommonRules(this)
|
|
.around(new JenkinsReadYamlRule(this))
|
|
//.around(jrj)
|
|
.around(jlr)
|
|
.around(jscr)
|
|
.around(jsr)
|
|
|
|
@Test
|
|
void testStashBeforeBuildNoOpa() {
|
|
|
|
jsr.step.call(script: nullScript, juStabUtils: utils)
|
|
|
|
// asserts
|
|
assertEquals('mkdir -p gitmetadata', jscr.shell[0])
|
|
assertEquals('cp -rf .git/* gitmetadata', jscr.shell[1])
|
|
assertEquals('chmod -R u+w gitmetadata', jscr.shell[2])
|
|
|
|
assertThat(jlr.log, containsString('Stash content: buildDescriptor'))
|
|
assertThat(jlr.log, containsString('Stash content: deployDescriptor'))
|
|
assertThat(jlr.log, containsString('Stash content: git'))
|
|
assertFalse(jlr.log.contains('Stash content: opa5'))
|
|
assertThat(jlr.log, containsString('Stash content: opensourceConfiguration'))
|
|
assertThat(jlr.log, containsString('Stash content: pipelineConfigAndTests'))
|
|
assertThat(jlr.log, containsString('Stash content: securityDescriptor'))
|
|
assertThat(jlr.log, containsString('Stash content: tests'))
|
|
}
|
|
|
|
@Test
|
|
void testStashBeforeBuildOpa() {
|
|
|
|
jsr.step.call(script: nullScript, juStabUtils: utils, runOpaTests: true)
|
|
|
|
// asserts
|
|
assertThat(jlr.log, containsString('Stash content: buildDescriptor'))
|
|
assertThat(jlr.log, containsString('Stash content: deployDescriptor'))
|
|
assertThat(jlr.log, containsString('Stash content: git'))
|
|
assertThat(jlr.log, containsString('Stash content: opa5'))
|
|
assertThat(jlr.log, containsString('Stash content: opensourceConfiguration'))
|
|
assertThat(jlr.log, containsString('Stash content: pipelineConfigAndTests'))
|
|
assertThat(jlr.log, containsString('Stash content: securityDescriptor'))
|
|
assertThat(jlr.log, containsString('Stash content: tests'))
|
|
}
|
|
}
|