1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-16 05:16:08 +02:00

fix: add missing return value for error (#5146)

This commit is contained in:
Srinikitha Kondreddy 2024-10-15 14:29:09 +02:00 committed by GitHub
parent bc8225cffb
commit bd8b08b93e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 2 deletions

View File

@ -194,7 +194,7 @@ func getFioriDeployStatement(
if len(app.Name) > 0 {
re := regexp.MustCompile(pattern)
if !re.MatchString(app.Name) {
fmt.Errorf("application name '%s' contains spaces or special characters. It is not according to the '%s'", app.Name, pattern)
return "", fmt.Errorf("application name '%s' contains spaces or special characters and is not according to the regex '%s'.", app.Name, pattern)
}
log.Entry().Debugf("application name '%s' used from piper config", app.Name)
cmd = append(cmd, "--name", app.Name)

View File

@ -4,10 +4,11 @@
package cts
import (
"testing"
"github.com/SAP/jenkins-library/pkg/mock"
"github.com/SAP/jenkins-library/pkg/piperutils"
"github.com/stretchr/testify/assert"
"testing"
)
func TestUploadCTS(t *testing.T) {
@ -99,6 +100,26 @@ func TestUploadCTS(t *testing.T) {
assert.Equal(t, []string{"ABAP_USER=me", "ABAP_PASSWORD=******"}, cmd.Env)
}
})
t.Run("fail in case of invalid app name", func(t *testing.T) {
cmd := mock.ShellMockRunner{}
action := UploadAction{
Connection: Connection{Endpoint: "https://example.org:8080/cts", Client: "001", User: "me", Password: "******"},
Application: Application{Pack: "abapPackage", Name: "app Name", Desc: "the Desc"},
Node: Node{
DeployDependencies: []string{},
InstallOpts: []string{},
},
TransportRequestID: "12345678",
ConfigFile: "ui5-deploy.yaml",
DeployUser: "doesNotMatterInThisCase",
}
err := action.Perform(&cmd)
expectedErrorMessge := "application name 'app Name' contains spaces or special characters and is not according to the regex '^[a-zA-Z0-9_]+$'."
assert.EqualErrorf(t, err, expectedErrorMessge, "invalid app name")
})
})
t.Run("config file releated tests", func(t *testing.T) {