mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-16 11:09:33 +02:00
68 lines
1.8 KiB
Groovy
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))
|
||
|
}
|
||
|
}
|