1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/test/groovy/PipelineStashFilesBeforeBuildTest.groovy

69 lines
2.6 KiB
Groovy
Raw Normal View History

import org.junit.After
import org.junit.Before
2018-05-30 12:00:13 +02:00
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import util.*
import com.sap.piper.Utils
2018-05-30 12:00:13 +02:00
import static org.hamcrest.Matchers.containsString
import static org.junit.Assert.*
class PipelineStashFilesBeforeBuildTest extends BasePiperTest {
2019-01-22 10:25:42 +02:00
JenkinsStepRule stepRule = new JenkinsStepRule(this)
JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
2019-01-22 10:19:28 +02:00
JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
//JenkinsReadJsonRule readJsonRule = new JenkinsReadJsonRule(this)
2018-05-30 12:00:13 +02:00
@Before
public void setup() {
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
2018-05-30 12:00:13 +02:00
@Rule
public RuleChain rules = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
//.around(readJsonRule)
.around(loggingRule)
2019-01-22 10:19:28 +02:00
.around(shellRule)
2019-01-22 10:25:42 +02:00
.around(stepRule)
2018-05-30 12:00:13 +02:00
@Test
void testStashBeforeBuild() {
2018-05-30 12:00:13 +02:00
stepRule.step.pipelineStashFilesBeforeBuild(script: nullScript, juStabUtils: utils, runOpaTests: true)
2018-05-30 12:00:13 +02:00
// asserts
assertThat(loggingRule.log, containsString('Stash content: buildDescriptor'))
assertThat(loggingRule.log, containsString('Stash content: deployDescriptor'))
assertThat(loggingRule.log, containsString('Stash content: git'))
assertThat(loggingRule.log, containsString('Stash content: opensourceConfiguration'))
assertThat(loggingRule.log, containsString('Stash content: pipelineConfigAndTests'))
assertThat(loggingRule.log, containsString('Stash content: securityDescriptor'))
assertThat(loggingRule.log, containsString('Stash content: tests'))
2018-05-30 12:00:13 +02:00
}
@Test
void testStashBeforeBuildCustomConfig() {
2018-05-30 12:00:13 +02:00
stepRule.step.pipelineStashFilesBeforeBuild(script: nullScript, juStabUtils: utils, runOpaTests: true, stashIncludes: ['myStash': '**.myTest'])
2018-05-30 12:00:13 +02:00
// asserts
assertThat(loggingRule.log, containsString('Stash content: buildDescriptor'))
assertThat(loggingRule.log, containsString('Stash content: deployDescriptor'))
assertThat(loggingRule.log, containsString('Stash content: git'))
assertThat(loggingRule.log, containsString('Stash content: opensourceConfiguration'))
assertThat(loggingRule.log, containsString('Stash content: pipelineConfigAndTests'))
assertThat(loggingRule.log, containsString('Stash content: securityDescriptor'))
assertThat(loggingRule.log, containsString('Stash content: tests'))
assertThat(loggingRule.log, containsString('Stash content: myStash'))
2018-05-30 12:00:13 +02:00
}
}