1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/test/groovy/com/sap/piper/versioning/MtaArtifactVersioningTest.groovy
Marcus Holl 6b7dc48c44 Be more flexible with JenkinsReadYaml rule
When we register a closure as file, the closure will be exectutd.
Otherwise we return what is registered.

This gives us a maximum level of flexibility. We can throw exceptions (e.g. FileNotFound) as
as test setup requires this, in simple cases we provide the yaml as a string.
2018-09-04 09:46:59 +02:00

31 lines
910 B
Groovy

package com.sap.piper.versioning
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import util.BasePiperTest
import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.Rules
import static org.junit.Assert.assertEquals
class MtaArtifactVersioningTest extends BasePiperTest{
JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this).registerYaml('mta.yaml', "version: '1.2.3'"))
.around(jscr)
@Test
void testVersioning() {
MtaArtifactVersioning av = new MtaArtifactVersioning(nullScript, [filePath: 'mta.yaml'])
assertEquals('1.2.3', av.getVersion())
av.setVersion('1.2.3-20180101')
assertEquals("sed -i 's/version: 1.2.3/version: 1.2.3-20180101/g' mta.yaml", jscr.shell[0])
}
}