forked from cloudfoundry/go-cfclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_provided_service_instances_test.go
69 lines (59 loc) · 2.78 KB
/
user_provided_service_instances_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
package cfclient
import (
"reflect"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestUserProvidedServiceInstanceByGuid(t *testing.T) {
Convey("Service instance by Guid", t, func() {
setup(MockRoute{"GET", "/v2/user_provided_service_instances/e9358711-0ad9-4f2a-b3dc-289d47c17c87", userProvidedServiceInstancePayload, "", 200, "", nil}, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
instance, err := client.GetUserProvidedServiceInstanceByGuid("e9358711-0ad9-4f2a-b3dc-289d47c17c87")
So(err, ShouldBeNil)
So(instance.Guid, ShouldEqual, "e9358711-0ad9-4f2a-b3dc-289d47c17c87")
So(reflect.DeepEqual(
instance.Credentials,
map[string]interface{}{"creds-key-58": "creds-val-58"}), ShouldBeTrue)
So(instance.Name, ShouldEqual, "name-1700")
So(instance.SpaceGuid, ShouldEqual, "22236d1a-d9c7-44b7-bdad-2bb079a6c4a1")
So(instance.RouteServiceUrl, ShouldEqual, "")
So(instance.Type, ShouldEqual, "user_provided_service_instance")
So(instance.SpaceUrl, ShouldEqual, "/v2/spaces/22236d1a-d9c7-44b7-bdad-2bb079a6c4a1")
So(instance.SyslogDrainUrl, ShouldEqual, "https://foo.com/url-104")
So(instance.ServiceBindingsUrl, ShouldEqual, "/v2/user_provided_service_instances/e9358711-0ad9-4f2a-b3dc-289d47c17c87/service_bindings")
So(instance.RoutesUrl, ShouldEqual, "/v2/user_provided_service_instances/e9358711-0ad9-4f2a-b3dc-289d47c17c87/routes")
})
}
func TestListUserProvidedServiceInstances(t *testing.T) {
Convey("List Service Instances", t, func() {
setup(MockRoute{"GET", "/v2/user_provided_service_instances", listUserProvidedServiceInstancePayload, "", 200, "", nil}, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
instances, err := client.ListUserProvidedServiceInstances()
So(err, ShouldBeNil)
instance := instances[0]
So(instance.Guid, ShouldEqual, "54e4c645-7d20-4271-8c27-8cc904e1e7ee")
So(reflect.DeepEqual(
instance.Credentials,
map[string]interface{}{"creds-key-57": "creds-val-57"}), ShouldBeTrue)
So(instance.Name, ShouldEqual, "name-1696")
So(instance.SpaceGuid, ShouldEqual, "87d14ac2-f396-460e-a523-dc1d77aba35a")
So(instance.RouteServiceUrl, ShouldEqual, "")
So(instance.Type, ShouldEqual, "user_provided_service_instance")
So(instance.SpaceUrl, ShouldEqual, "/v2/spaces/87d14ac2-f396-460e-a523-dc1d77aba35a")
So(instance.SyslogDrainUrl, ShouldEqual, "https://foo.com/url-103")
So(instance.ServiceBindingsUrl, ShouldEqual, "/v2/user_provided_service_instances/54e4c645-7d20-4271-8c27-8cc904e1e7ee/service_bindings")
So(instance.RoutesUrl, ShouldEqual, "/v2/user_provided_service_instances/54e4c645-7d20-4271-8c27-8cc904e1e7ee/routes")
})
}