You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-09-16 09:26:22 +02:00
@@ -194,6 +194,7 @@ public class CommonStepsTest extends BasePiperTest{
|
||||
'transportRequestUploadRFC', //implementing new golang pattern without fields
|
||||
'writePipelineEnv', //implementing new golang pattern without fields
|
||||
'readPipelineEnv', //implementing new golang pattern without fields
|
||||
'transportRequestUploadCTS', //implementing new golang pattern without fields
|
||||
]
|
||||
|
||||
@Test
|
||||
|
65
test/groovy/TransportRequestUploadCTSTest.groovy
Normal file
65
test/groovy/TransportRequestUploadCTSTest.groovy
Normal file
@@ -0,0 +1,65 @@
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.RuleChain
|
||||
import org.yaml.snakeyaml.parser.ParserException
|
||||
|
||||
import hudson.AbortException
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsDockerExecuteRule
|
||||
import util.JenkinsLoggingRule
|
||||
import util.JenkinsReadYamlRule
|
||||
import util.JenkinsShellCallRule
|
||||
import util.JenkinsStepRule
|
||||
import util.JenkinsWriteFileRule
|
||||
import util.Rules
|
||||
|
||||
import static org.hamcrest.Matchers.*
|
||||
import static org.junit.Assert.assertThat
|
||||
import static org.hamcrest.Matchers.hasEntry
|
||||
|
||||
public class TransportRequestUploadCTSTest extends BasePiperTest {
|
||||
|
||||
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
||||
private JenkinsReadYamlRule readYamlRule = new JenkinsReadYamlRule(this)
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules
|
||||
.getCommonRules(this)
|
||||
.around(stepRule)
|
||||
.around(readYamlRule)
|
||||
|
||||
@Test
|
||||
void testCallGoWrapper() {
|
||||
|
||||
def calledWithParameters,
|
||||
calledWithStepName,
|
||||
calledWithMetadata
|
||||
List calledWithCredentials
|
||||
|
||||
helper.registerAllowedMethod(
|
||||
'piperExecuteBin',
|
||||
[Map, String, String, List],
|
||||
{
|
||||
params, stepName, metaData, creds ->
|
||||
calledWithParameters = params
|
||||
calledWithStepName = stepName
|
||||
calledWithMetadata = metaData
|
||||
calledWithCredentials = creds
|
||||
}
|
||||
)
|
||||
|
||||
stepRule.step.transportRequestUploadCTS(script: nullScript, abc: 'CF')
|
||||
|
||||
assertThat(calledWithParameters.size(), is(2))
|
||||
assertThat(calledWithParameters.script, is(nullScript))
|
||||
assertThat(calledWithParameters.abc, is('CF'))
|
||||
|
||||
assertThat(calledWithStepName, is('transportRequestUploadCTS'))
|
||||
assertThat(calledWithMetadata, is('metadata/transportRequestUploadCTS.yaml'))
|
||||
assertThat(calledWithCredentials[0].size(), is(3))
|
||||
assertThat(calledWithCredentials[0], allOf(hasEntry('type','usernamePassword'), hasEntry('id','uploadCredentialsId'), hasEntry('env',['PIPER_username', 'PIPER_password'])))
|
||||
}
|
||||
}
|
17
vars/transportRequestUploadCTS.groovy
Normal file
17
vars/transportRequestUploadCTS.groovy
Normal file
@@ -0,0 +1,17 @@
|
||||
import com.sap.piper.BuildTool
|
||||
import groovy.transform.Field
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
import com.sap.piper.DownloadCacheUtils
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field String METADATA_FILE = 'metadata/transportRequestUploadCTS.yaml'
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
final script = checkScript(this, parameters) ?: this
|
||||
parameters = DownloadCacheUtils.injectDownloadCacheInParameters(script, parameters, BuildTool.NPM)
|
||||
|
||||
List credentials = [
|
||||
[type: 'usernamePassword', id: 'uploadCredentialsId', env: ['PIPER_username', 'PIPER_password']]
|
||||
]
|
||||
piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials)
|
||||
}
|
Reference in New Issue
Block a user