1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-03 15:02:35 +02:00

xsDeploy: check for operationId in go layer and return error in case it is missing (#1109)

This commit is contained in:
Marcus Holl 2020-02-28 09:40:22 +01:00 committed by GitHub
parent b4de8f2950
commit 161e0b5d3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -265,6 +265,9 @@ func runXsDeploy(XsDeployOptions xsDeployOptions, s shellRunner,
if err == nil && (mode == BGDeploy && action == None) {
XsDeployOptions.OperationID = retrieveOperationID(o, XsDeployOptions.OperationIDLogPattern)
if len(XsDeployOptions.OperationID) == 0 {
err = errors.New("No operationID found")
}
}
if err != nil {

View File

@ -182,8 +182,12 @@ func TestDeploy(t *testing.T) {
fileUtilsMock.copiedFiles = nil
removedFiles = nil
s.Calls = nil
s.StdoutReturn = make(map[string]string)
}()
s.StdoutReturn = make(map[string]string)
s.StdoutReturn[".*xs bg-deploy.*"] = "Use \"xs bg-deploy -i 1234 -a resume\" to resume the process.\n"
oldMode := myXsDeployOptions.Mode
defer func() {
@ -200,6 +204,30 @@ func TestDeploy(t *testing.T) {
assert.Len(t, s.Calls, 2) // There are two entries --> no logout in this case.
})
t.Run("BG deploy fails, missing operationID", func(t *testing.T) {
defer func() {
fileUtilsMock.copiedFiles = nil
removedFiles = nil
s.Calls = nil
s.StdoutReturn = make(map[string]string)
}()
s.StdoutReturn = make(map[string]string)
s.StdoutReturn[".*xs bg-deploy.*"] = "There is no operation id\n"
oldMode := myXsDeployOptions.Mode
defer func() {
myXsDeployOptions.Mode = oldMode
}()
myXsDeployOptions.Mode = "BG_DEPLOY"
e := runXsDeploy(myXsDeployOptions, &s, &fileUtilsMock, fRemove, ioutil.Discard)
checkErr(t, e, "No operationID found")
})
t.Run("BG deploy abort succeeds", func(t *testing.T) {
defer func() {