forked from aiven/aiven-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_test.go
68 lines (56 loc) · 1.69 KB
/
service_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
package aiven_test
import (
"testing"
"github.com/jelmersnoeck/aiven"
"github.com/jelmersnoeck/aiven/internal/testhelpers"
)
func TestService(t *testing.T) {
pn := testhelpers.ProjectName("service")
cl := testhelpers.Client()
_, err := testhelpers.NewProject(cl, pn)
if err != nil {
t.Errorf("Error creating project: %s", err)
return
}
defer func() {
if err := cl.Projects.Delete(pn); err != nil {
t.Errorf("Error deleting project: %s", err)
}
}()
t.Run("integration test", func(t *testing.T) {
t.Run("with all required params", func(t *testing.T) {
var service *aiven.Service
var err error
serviceName := testhelpers.ProjectName("successful-pg")
t.Run("it should create the service without errors", func(t *testing.T) {
service, err = cl.Services.Create(pn, aiven.CreateServiceRequest{
Plan: testhelpers.ServicePlan,
ServiceName: serviceName,
ServiceType: "pg",
})
if err != nil {
t.Errorf("Expected error to be nil, got %s", err)
}
if service == nil {
t.Errorf("Expected service to be created, got %s", err)
}
})
t.Run("it should get the service without errors", func(t *testing.T) {
service, err = cl.Services.Get(pn, serviceName)
if err != nil {
t.Errorf("Expected error to be nil, got %s", err)
}
if service == nil {
t.Errorf("Expected service to be fetched, got %s", err)
}
})
t.Run("it should update the service without errors", func(t *testing.T) {
})
t.Run("it should delete the service without errors", func(t *testing.T) {
if err = cl.Services.Delete(pn, serviceName); err != nil {
t.Errorf("Expected service to be nil, got %s", err)
}
})
})
})
}