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/EnvironmentUtilsTest.groovy
Stephan Aßmus 1d9ecdb999 Added EnvironmentUtils needed by DebugReport
This should have been added along with DebugReport. For context:
EnvironmentUtils used to be a class alongside DebugReport and thus
there was no 'import' directive. Working with Jenkins DSL stuff
has numbed my ability to pay attention to the IDE indicating errors.
2020-02-03 17:07:56 +01:00

68 lines
1.8 KiB
Groovy

package com.sap.piper
import org.junit.Assert
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import util.BasePiperTest
import util.JenkinsLoggingRule
import util.Rules
class EnvironmentUtilsTest {
@Test
void testCxServerDirectoryExists() {
Assert.assertFalse(EnvironmentUtils.cxServerDirectoryExists())
}
@Test
void testGetDockerFile() {
String cxServerCfgContents = '''
#---------------------------------------------#
#-- Build server configuration ---------------#
#---------------------------------------------#
#>> Address of the used docker registry. Override if you do not want to use Docker's default registry.
docker_registry=some_registry
#>> Name of the used docker image
docker_image="some_path/some_file"
#>> Enable TLS encryption
tls_enabled=true
'''
Assert.assertEquals( 'some_path/some_file',
EnvironmentUtils.getDockerFile(cxServerCfgContents))
}
@Test
void testGetDockerFileSpaces() {
String cxServerCfgContents = '''
#>> Name of the used docker image
docker_image = "some_path/some_file:latest"
'''
Assert.assertEquals( 'some_path/some_file:latest',
EnvironmentUtils.getDockerFile(cxServerCfgContents))
}
@Test
void testGetDockerFileTrailingSpaces() {
String cxServerCfgContents = '''
#>> Name of the used docker image
docker_image="some_path/some_file:latest"
'''
Assert.assertEquals( 'some_path/some_file:latest',
EnvironmentUtils.getDockerFile(cxServerCfgContents))
}
@Test
void testGetDockerFileSpacesInPath() {
String cxServerCfgContents = '''
#>> Name of the used docker image
docker_image = "some path/some file:latest"
'''
Assert.assertEquals( 'some path/some file:latest',
EnvironmentUtils.getDockerFile(cxServerCfgContents))
}
}