|
4 | 4 | package cts
|
5 | 5 |
|
6 | 6 | import (
|
| 7 | + "testing" |
| 8 | + |
7 | 9 | "github.com/SAP/jenkins-library/pkg/mock"
|
8 | 10 | "github.com/SAP/jenkins-library/pkg/piperutils"
|
9 | 11 | "github.com/stretchr/testify/assert"
|
10 |
| - "testing" |
11 | 12 | )
|
12 | 13 |
|
13 | 14 | func TestUploadCTS(t *testing.T) {
|
@@ -99,6 +100,26 @@ func TestUploadCTS(t *testing.T) {
|
99 | 100 | assert.Equal(t, []string{"ABAP_USER=me", "ABAP_PASSWORD=******"}, cmd.Env)
|
100 | 101 | }
|
101 | 102 | })
|
| 103 | + |
| 104 | + t.Run("fail in case of invalid app name", func(t *testing.T) { |
| 105 | + cmd := mock.ShellMockRunner{} |
| 106 | + action := UploadAction{ |
| 107 | + Connection: Connection{Endpoint: "https://example.org:8080/cts", Client: "001", User: "me", Password: "******"}, |
| 108 | + Application: Application{Pack: "abapPackage", Name: "app Name", Desc: "the Desc"}, |
| 109 | + Node: Node{ |
| 110 | + DeployDependencies: []string{}, |
| 111 | + InstallOpts: []string{}, |
| 112 | + }, |
| 113 | + TransportRequestID: "12345678", |
| 114 | + ConfigFile: "ui5-deploy.yaml", |
| 115 | + DeployUser: "doesNotMatterInThisCase", |
| 116 | + } |
| 117 | + |
| 118 | + err := action.Perform(&cmd) |
| 119 | + expectedErrorMessge := "application name 'app Name' contains spaces or special characters and is not according to the regex '^[a-zA-Z0-9_]+$'." |
| 120 | + |
| 121 | + assert.EqualErrorf(t, err, expectedErrorMessge, "invalid app name") |
| 122 | + }) |
102 | 123 | })
|
103 | 124 |
|
104 | 125 | t.Run("config file releated tests", func(t *testing.T) {
|
|
0 commit comments