1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00

Merge remote-tracking branch 'github/master' into HEAD

This commit is contained in:
Marcus Holl 2018-09-21 12:16:50 +02:00
commit f0820fa399
7 changed files with 11 additions and 28 deletions

View File

@ -117,7 +117,7 @@ otherwise in the [LICENSE file][piper-library-license]
[piper-library-pages-plugins]: https://sap.github.io/jenkins-library/jenkins/requiredPlugins [piper-library-pages-plugins]: https://sap.github.io/jenkins-library/jenkins/requiredPlugins
[piper-library-issues]: https://github.com/SAP/jenkins-library/issues [piper-library-issues]: https://github.com/SAP/jenkins-library/issues
[piper-library-license]: ./LICENSE [piper-library-license]: ./LICENSE
[piper-library-contribution]: ./CONTRIBUTING.md [piper-library-contribution]: .github/CONTRIBUTING.md
[jenkins-doc-pipelines]: https://jenkins.io/solutions/pipeline [jenkins-doc-pipelines]: https://jenkins.io/solutions/pipeline
[jenkins-doc-libraries]: https://jenkins.io/doc/book/pipeline/shared-libraries [jenkins-doc-libraries]: https://jenkins.io/doc/book/pipeline/shared-libraries
[jenkins-doc-steps]: https://jenkins.io/doc/pipeline/steps [jenkins-doc-steps]: https://jenkins.io/doc/pipeline/steps

View File

@ -156,11 +156,4 @@ class ArtifactSetVersionTest extends BasePiperTest {
) )
assertThat(sshAgentList, hasItem('testCredentials')) assertThat(sshAgentList, hasItem('testCredentials'))
} }
void prepareObjectInterceptors(object) {
object.metaClass.invokeMethod = helper.getMethodInterceptor()
object.metaClass.static.invokeMethod = helper.getMethodInterceptor()
object.metaClass.methodMissing = helper.getMethodMissingInterceptor()
}
} }

View File

@ -19,8 +19,13 @@ import static org.junit.Assert.assertNotNull
import static org.junit.Assert.assertNull import static org.junit.Assert.assertNull
import static org.junit.Assert.assertThat import static org.junit.Assert.assertThat
import org.springframework.beans.factory.annotation.Autowired
class GitUtilsTest extends BasePiperTest { class GitUtilsTest extends BasePiperTest {
@Autowired
GitUtils gitUtils
JenkinsShellCallRule jscr = new JenkinsShellCallRule(this) JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
ExpectedException thrown = ExpectedException.none() ExpectedException thrown = ExpectedException.none()

View File

@ -39,10 +39,7 @@ class MtaUtilsTest extends BasePiperTest {
@Before @Before
void init() { void init() {
targetMtaDescriptor = "${tmp.getRoot()}/generated_mta.yml" targetMtaDescriptor = "${tmp.getRoot()}/generated_mta.yml"
def script = new Object() mtaUtils = new MtaUtils(nullScript)
mtaUtils = new MtaUtils(script)
prepareObjectInterceptors(script)
this.helper.registerAllowedMethod('readJSON', [Map], { Map parameters -> this.helper.registerAllowedMethod('readJSON', [Map], { Map parameters ->
return new JsonSlurper().parse(new File(parameters.file)) return new JsonSlurper().parse(new File(parameters.file))

View File

@ -40,13 +40,11 @@ class DockerArtifactVersioningTest extends BasePiperTest{
passedDir = s passedDir = s
return closure() return closure()
}) })
prepareObjectInterceptors(this)
} }
@Test @Test
void testVersioningFrom() { void testVersioningFrom() {
av = new DockerArtifactVersioning(this, [filePath: 'Dockerfile', dockerVersionSource: 'FROM']) av = new DockerArtifactVersioning(nullScript, [filePath: 'Dockerfile', dockerVersionSource: 'FROM'])
assertEquals('1.2.3', av.getVersion()) assertEquals('1.2.3', av.getVersion())
av.setVersion('1.2.3-20180101') av.setVersion('1.2.3-20180101')
assertEquals('1.2.3-20180101', jwfr.files['VERSION']) assertEquals('1.2.3-20180101', jwfr.files['VERSION'])
@ -55,15 +53,8 @@ class DockerArtifactVersioningTest extends BasePiperTest{
@Test @Test
void testVersioningEnv() { void testVersioningEnv() {
av = new DockerArtifactVersioning(this, [filePath: 'Dockerfile', dockerVersionSource: 'TEST']) av = new DockerArtifactVersioning(nullScript, [filePath: 'Dockerfile', dockerVersionSource: 'TEST'])
assertEquals('2.3.4', av.getVersion()) assertEquals('2.3.4', av.getVersion())
assertTrue(jlr.log.contains('[DockerArtifactVersioning] Version from Docker environment variable TEST: 2.3.4')) assertTrue(jlr.log.contains('[DockerArtifactVersioning] Version from Docker environment variable TEST: 2.3.4'))
} }
void prepareObjectInterceptors(object) {
object.metaClass.invokeMethod = helper.getMethodInterceptor()
object.metaClass.static.invokeMethod = helper.getMethodInterceptor()
object.metaClass.methodMissing = helper.getMethodMissingInterceptor()
}
} }

View File

@ -20,9 +20,6 @@ abstract class BasePiperTest extends BasePipelineTest {
@Autowired @Autowired
Script nullScript Script nullScript
@Autowired
GitUtils gitUtils
@Autowired @Autowired
Utils utils Utils utils

View File

@ -30,8 +30,8 @@ class BasePiperTestContext {
Utils mockUtils() { Utils mockUtils() {
def mockUtils = new Utils() def mockUtils = new Utils()
mockUtils.steps = [ mockUtils.steps = [
stash : { m -> println "stash name = ${m.name}" }, stash : { },
unstash: { println "unstash called ..." } unstash: { }
] ]
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(mockUtils) LibraryLoadingTestExecutionListener.prepareObjectInterceptors(mockUtils)
return mockUtils return mockUtils