-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathproject_acc_test.go
140 lines (122 loc) · 3.94 KB
/
project_acc_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package aiven
import (
"context"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Projects", func() {
var (
projectName string
billingGName string
project *Project
billingG *BillingGroup
err error
)
ctx := context.Background()
BeforeEach(func() {
billingGName = "test-acc-bg-" + generateRandomID()
billingG, err = client.BillingGroup.Create(ctx, BillingGroupRequest{
BillingGroupName: billingGName,
Company: ToStringPointer("testC1"),
AddressLines: []string{"NYC Some Street 123 A"},
CountryCode: ToStringPointer("US"),
City: ToStringPointer("NY"),
ZipCode: ToStringPointer("101778"),
BillingCurrency: ToStringPointer("EUR"),
})
projectName = "test-acc-pr" + generateRandomID()
project, err = client.Projects.Create(ctx, CreateProjectRequest{
Project: projectName,
BillingCurrency: "EUR",
TechnicalEmails: ContactEmailFromStringSlice([]string{"[email protected]"}),
UseSourceProjectBillingGroup: false,
BillingGroupId: billingG.Id,
Tags: map[string]string{},
})
})
Context("Create new project", func() {
It("should not error", func() {
if !IsAlreadyExists(err) {
Expect(err).NotTo(HaveOccurred())
}
})
It("should populate fields properly", func() {
project, err = client.Projects.Get(ctx, projectName)
Expect(err).NotTo(HaveOccurred())
Expect(project).NotTo(BeNil())
if project != nil {
Expect(project.Name).NotTo(BeEmpty())
Expect(project.AccountId).To(BeEmpty())
Expect(project.BillingCurrency).NotTo(BeEmpty())
Expect(project.GetTechnicalEmailsAsStringSlice()).NotTo(BeEmpty())
Expect(project.BillingGroupId).NotTo(BeEmpty())
Expect(project.BillingGroupName).Should(Equal(billingGName))
}
})
It("update project name", func() {
project, err = client.Projects.Update(ctx, projectName, UpdateProjectRequest{
Name: projectName + "-new",
Tags: map[string]string{},
})
if err == nil {
projectName = projectName + "-new"
}
Expect(err).NotTo(HaveOccurred())
Expect(project).NotTo(BeNil())
})
})
Context("Get project event logs", func() {
It("should be event logs", func() {
events, logErr := client.Projects.GetEventLog(ctx, projectName)
Expect(logErr).To(BeNil())
Expect(events).ToNot(BeNil())
Expect(events).Should(Not(BeEmpty()))
for _, event := range events {
Expect(event).NotTo(BeNil())
}
})
})
Context("Get service types", func() {
It("check returned service types", func() {
serviceTypes, err := client.Projects.ServiceTypes(ctx, projectName)
Expect(err).To(BeNil())
Expect(serviceTypes).ToNot(BeNil())
Expect(serviceTypes).Should(Not(BeEmpty()))
for _, serviceType := range serviceTypes {
Expect(serviceType).NotTo(BeNil())
}
})
})
Context("Get integration types", func() {
It("check returned integration types", func() {
integrationTypes, err := client.Projects.IntegrationTypes(ctx, projectName)
Expect(err).To(BeNil())
Expect(integrationTypes).ToNot(BeNil())
Expect(integrationTypes).Should(Not(BeEmpty()))
for _, integrationType := range integrationTypes {
Expect(integrationType).NotTo(BeNil())
}
})
})
Context("Get integration endpoint types", func() {
It("check returned integration endpoint types", func() {
endpointTypes, err := client.Projects.IntegrationEndpointTypes(ctx, projectName)
Expect(err).To(BeNil())
Expect(endpointTypes).ToNot(BeNil())
Expect(endpointTypes).Should(Not(BeEmpty()))
for _, endpointType := range endpointTypes {
Expect(endpointType).NotTo(BeNil())
}
})
})
AfterEach(func() {
err = client.Projects.Delete(ctx, projectName)
if err != nil {
Fail("cannot delete project : " + err.Error())
}
err = client.BillingGroup.Delete(ctx, billingG.Id)
if err != nil {
Fail("cannot delete billing group : " + err.Error())
}
})
})