mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
fd568c9174
* do not swallow exception triggered inside SWA handling --> write it to the log The real change is in src/com/sap/piper/Utils.groovy All the changes in the tests are dealing with mocking the echo method used in the Utils class mentioned above.
69 lines
2.6 KiB
Groovy
69 lines
2.6 KiB
Groovy
import org.junit.After
|
|
import org.junit.Before
|
|
import org.junit.Rule
|
|
import org.junit.Test
|
|
import org.junit.rules.RuleChain
|
|
import util.*
|
|
|
|
import com.sap.piper.Utils
|
|
|
|
import static org.hamcrest.Matchers.containsString
|
|
import static org.junit.Assert.*
|
|
|
|
class PipelineStashFilesBeforeBuildTest extends BasePiperTest {
|
|
JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
|
JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
|
|
JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
|
|
//JenkinsReadJsonRule readJsonRule = new JenkinsReadJsonRule(this)
|
|
|
|
@Before
|
|
public void setup() {
|
|
Utils.metaClass.echo = { def m -> }
|
|
}
|
|
|
|
@After
|
|
public void tearDown() {
|
|
Utils.metaClass = null
|
|
}
|
|
|
|
@Rule
|
|
public RuleChain rules = Rules
|
|
.getCommonRules(this)
|
|
.around(new JenkinsReadYamlRule(this))
|
|
//.around(readJsonRule)
|
|
.around(loggingRule)
|
|
.around(shellRule)
|
|
.around(stepRule)
|
|
|
|
@Test
|
|
void testStashBeforeBuild() {
|
|
|
|
stepRule.step.pipelineStashFilesBeforeBuild(script: nullScript, juStabUtils: utils, runOpaTests: true)
|
|
|
|
// 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'))
|
|
}
|
|
|
|
@Test
|
|
void testStashBeforeBuildCustomConfig() {
|
|
|
|
stepRule.step.pipelineStashFilesBeforeBuild(script: nullScript, juStabUtils: utils, runOpaTests: true, stashIncludes: ['myStash': '**.myTest'])
|
|
|
|
// 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'))
|
|
}
|
|
}
|