forked from cloudfoundry/go-cfclient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdomains_test.go
More file actions
86 lines (73 loc) · 2.5 KB
/
Copy pathdomains_test.go
File metadata and controls
86 lines (73 loc) · 2.5 KB
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
package cfclient
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestListDomains(t *testing.T) {
Convey("List domains", t, func() {
setup(MockRoute{"GET", "/v2/private_domains", listDomainsPayload, "", 200, ""}, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
domains, err := client.ListDomains()
So(err, ShouldBeNil)
So(len(domains), ShouldEqual, 4)
So(domains[0].Guid, ShouldEqual, "b2a35f0c-d5ad-4a59-bea7-461711d96b0d")
So(domains[0].Name, ShouldEqual, "vcap.me")
So(domains[0].OwningOrganizationGuid, ShouldEqual, "4cf3bc47-eccd-4662-9322-7833c3bdcded")
So(domains[0].OwningOrganizationUrl, ShouldEqual, "/v2/organizations/4cf3bc47-eccd-4662-9322-7833c3bdcded")
So(domains[0].SharedOrganizationsUrl, ShouldEqual, "/v2/private_domains/b2a35f0c-d5ad-4a59-bea7-461711d96b0d/shared_organizations")
})
}
func TestListSharedDomains(t *testing.T) {
Convey("List shared domains", t, func() {
setup(MockRoute{"GET", "/v2/shared_domains", listSharedDomainsPayload, "", 200, ""}, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
domains, err := client.ListSharedDomains()
So(err, ShouldBeNil)
So(len(domains), ShouldEqual, 1)
So(domains[0].Guid, ShouldEqual, "91977695-8ad9-40db-858f-4df782603ec3")
So(domains[0].Name, ShouldEqual, "domain-49.example.com")
So(domains[0].RouterGroupGuid, ShouldEqual, "my-random-guid")
So(domains[0].RouterGroupType, ShouldEqual, "tcp")
})
}
func TestCreateDomain(t *testing.T) {
Convey("Create domain", t, func() {
setup(MockRoute{"POST", "/v2/private_domains", postDomainPayload, "", 201, ""}, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
domain, err := client.CreateDomain("exmaple.com", "8483e4f1-d3a3-43e2-ab8c-b05ea40ef8db")
So(err, ShouldBeNil)
So(domain.Guid, ShouldEqual, "b98aeca1-22b9-49f9-8428-3ace9ea2ba11")
})
}
func TestDeleteDomain(t *testing.T) {
Convey("Delete domain", t, func() {
setup(MockRoute{"DELETE", "/v2/private_domains/b2a35f0c-d5ad-4a59-bea7-461711d96b0d", "", "", 204, ""}, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
err = client.DeleteDomain("b2a35f0c-d5ad-4a59-bea7-461711d96b0d")
So(err, ShouldBeNil)
})
}