mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-03-05 15:15:44 +02:00
Fail early if file which should be uploaded does not exist. (#909)
Right now we fail with some error message from curl.
This commit is contained in:
parent
8cfac8d43f
commit
514755e4ef
@ -1,5 +1,8 @@
|
||||
import com.sap.piper.JenkinsUtils
|
||||
import com.sap.piper.integration.TransportManagementService
|
||||
|
||||
import hudson.AbortException
|
||||
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@ -19,6 +22,7 @@ public class TmsUploadTest extends BasePiperTest {
|
||||
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
||||
private JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
|
||||
private JenkinsEnvironmentRule envRule = new JenkinsEnvironmentRule(this)
|
||||
private JenkinsFileExistsRule fileExistsRules = new JenkinsFileExistsRule(this, ['dummy.mtar'])
|
||||
|
||||
def tmsStub
|
||||
def jenkinsUtilsStub
|
||||
@ -56,6 +60,7 @@ public class TmsUploadTest extends BasePiperTest {
|
||||
.around(stepRule)
|
||||
.around(loggingRule)
|
||||
.around(envRule)
|
||||
.around(fileExistsRules)
|
||||
.around(new JenkinsCredentialsRule(this)
|
||||
.withCredentials('TMS_ServiceKey', serviceKeyContent))
|
||||
|
||||
@ -161,6 +166,27 @@ public class TmsUploadTest extends BasePiperTest {
|
||||
assertThat(loggingRule.log, containsString("[TransportManagementService] Corresponding Transport Request: 'My custom description for testing.' (Id: '2000')"))
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failOnMissingMtaFile() {
|
||||
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage('Mta file \'dummy.mtar\' does not exist.')
|
||||
|
||||
fileExistsRules.existingFiles.remove('dummy.mtar')
|
||||
jenkinsUtilsStub = new JenkinsUtilsMock("Test User")
|
||||
|
||||
stepRule.step.tmsUpload(
|
||||
script: nullScript,
|
||||
juStabUtils: utils,
|
||||
jenkinsUtilsStub: jenkinsUtilsStub,
|
||||
transportManagementService: tmsStub,
|
||||
mtaPath: 'dummy.mtar',
|
||||
nodeName: 'myNode',
|
||||
credentialsId: 'TMS_ServiceKey',
|
||||
customDescription: 'My custom description for testing.'
|
||||
)
|
||||
}
|
||||
|
||||
def mockTransportManagementService() {
|
||||
return new TransportManagementService(nullScript, [:]) {
|
||||
def authentication(String uaaUrl, String oauthClientId, String oauthClientSecret) {
|
||||
|
@ -94,6 +94,10 @@ void call(Map parameters = [:]) {
|
||||
def nodeName = config.nodeName
|
||||
def mtaPath = config.mtaPath
|
||||
|
||||
if(!fileExists(mtaPath)) {
|
||||
error("Mta file '${mtaPath}' does not exist.")
|
||||
}
|
||||
|
||||
if (config.verbose) {
|
||||
echo "[TransportManagementService] CredentialsId: '${config.credentialsId}'"
|
||||
echo "[TransportManagementService] Node name: '${nodeName}'"
|
||||
|
Loading…
x
Reference in New Issue
Block a user