forked from SAP/jenkins-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegrationArtifactUnDeploy_test.go
62 lines (51 loc) · 1.56 KB
/
integrationArtifactUnDeploy_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package cmd
import (
"github.com/SAP/jenkins-library/pkg/mock"
"github.com/stretchr/testify/assert"
"testing"
)
type integrationArtifactUnDeployMockUtils struct {
*mock.ExecMockRunner
*mock.FilesMock
}
func TestRunIntegrationArtifactUnDeploy(t *testing.T) {
t.Parallel()
t.Run("Successful undeploy of integration flow test", func(t *testing.T) {
apiServiceKey := `{
"oauth": {
"url": "https://demo",
"clientid": "demouser",
"clientsecret": "******",
"tokenurl": "https://demo/oauth/token"
}
}`
config := integrationArtifactUnDeployOptions{
APIServiceKey: apiServiceKey,
IntegrationFlowID: "flow1",
}
httpClient := httpMockCpis{CPIFunction: "PositiveAndUnDeployIntegrationDesigntimeArtifact", ResponseBody: ``, TestType: "Positive"}
// test
err := runIntegrationArtifactUnDeploy(&config, nil, &httpClient)
// assert
assert.NoError(t, err)
})
t.Run("Failed undeploy of integration flow test", func(t *testing.T) {
apiServiceKey := `{
"oauth": {
"url": "https://demo",
"clientid": "demouser",
"clientsecret": "******",
"tokenurl": "https://demo/oauth/token"
}
}`
config := integrationArtifactUnDeployOptions{
APIServiceKey: apiServiceKey,
IntegrationFlowID: "flow1",
}
httpClient := httpMockCpis{CPIFunction: "FailedIntegrationRuntimeArtifactUnDeployment", ResponseBody: ``, TestType: "Negative"}
// test
err := runIntegrationArtifactUnDeploy(&config, nil, &httpClient)
// assert
assert.EqualError(t, err, "integration flow undeployment failed, response Status code: 400")
})
}