forked from aiven/aiven-go-client
-
Notifications
You must be signed in to change notification settings - Fork 1
/
project_acc_test.go
98 lines (85 loc) · 2.62 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
package aiven
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Projects", func() {
var (
projectName string
billingGName string
project *Project
billingG *BillingGroup
err error
)
BeforeEach(func() {
billingGName = "test-acc-bg-" + generateRandomID()
billingG, err = client.BillingGroup.Create(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(CreateProjectRequest{
Project: projectName,
BillingCurrency: "EUR",
TechnicalEmails: ContactEmailFromStringSlice([]string{"[email protected]"}),
UseSourceProjectBillingGroup: false,
BillingGroupId: billingG.Id,
})
})
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(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(projectName, UpdateProjectRequest{
Name: projectName + "-new",
})
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(projectName)
Expect(logErr).To(BeNil())
Expect(events).ToNot(BeNil())
Expect(events).Should(Not(BeEmpty()))
for _, event := range events {
Expect(event).NotTo(BeNil())
}
})
})
AfterEach(func() {
err = client.Projects.Delete(projectName)
if err != nil {
Fail("cannot delete project : " + err.Error())
}
err = client.BillingGroup.Delete(billingG.Id)
if err != nil {
Fail("cannot delete billing group : " + err.Error())
}
})
})