mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
26ecbe5013
We can now registering files to JenkinsReadYamlRule by providing the file name alongside with the expected content (or e.g. an expception) With that change it is possible to remove pwd statements from mtaBuild. These statements was used in order to pass a temporary directory inside the mtaBuild (code under test). This is not needed anymore since we can register the files directly. Having pwd implies working with absolute pathes which is also a no-go when working with docker, since the absolute pathes inside and outside docker are normally not the same. For pathes relative to a build root directory it is rather easy to keep the pathes consistent the same. Adjust sources according to registering yaml file to jenkins rule. For mtaBuild this means also: get ride of absolute pathes for denoting the yaml file. Having absolute pathes makes it difficult/impossible to work also with dockerized versions of mtaBuild since the absolute pathes are most probably not the same inside and outside the docker container, but the relatives pathes can be kept the same easily.
31 lines
912 B
Groovy
31 lines
912 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])
|
|
}
|
|
}
|