forked from pivotal-cf/brokerapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatalog_test.go
108 lines (94 loc) · 3.11 KB
/
catalog_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
package brokerapi_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/pivotal-cf/brokerapi/matchers"
"github.com/pivotal-cf/brokerapi"
)
var _ = Describe("Catalog", func() {
Describe("Service", func() {
Describe("JSON encoding", func() {
It("uses the correct keys", func() {
service := brokerapi.Service{
ID: "ID-1",
Name: "Cassandra",
Description: "A Cassandra Plan",
Bindable: true,
Plans: []brokerapi.ServicePlan{},
Metadata: brokerapi.ServiceMetadata{},
Tags: []string{},
PlanUpdatable: true,
}
json := `{"id":"ID-1","name":"Cassandra","description":"A Cassandra Plan","bindable":true,"plan_updateable":true,"plans":[],"metadata":{"displayName":"","longDescription":"","documentationUrl":"","supportUrl":"","listing":{"blurb":"","imageUrl":""},"provider":{"name":""}},"tags":[]}`
Expect(service).To(MarshalToJSON(json))
})
})
})
Describe("ServicePlan", func() {
Describe("JSON encoding", func() {
It("uses the correct keys", func() {
plan := brokerapi.ServicePlan{
ID: "ID-1",
Name: "Cassandra",
Description: "A Cassandra Plan",
Metadata: brokerapi.ServicePlanMetadata{
Bullets: []string{},
},
}
json := `{"id":"ID-1","name":"Cassandra","description":"A Cassandra Plan","metadata":{"bullets":[],"displayName":""}}`
Expect(plan).To(MarshalToJSON(json))
})
})
})
Describe("ServicePlanMetadata", func() {
Describe("JSON encoding", func() {
It("uses the correct keys", func() {
metadata := brokerapi.ServicePlanMetadata{
Bullets: []string{},
DisplayName: "Some display name",
}
json := `{"bullets":[],"displayName":"Some display name"}`
Expect(metadata).To(MarshalToJSON(json))
})
})
})
Describe("ServiceMetadata", func() {
Describe("JSON encoding", func() {
It("uses the correct keys", func() {
metadata := brokerapi.ServiceMetadata{
DisplayName: "Cassandra",
LongDescription: "A long description of Cassandra",
DocumentationUrl: "",
SupportUrl: "",
Listing: brokerapi.ServiceMetadataListing{},
Provider: brokerapi.ServiceMetadataProvider{},
}
json := `{"displayName":"Cassandra","longDescription":"A long description of Cassandra","documentationUrl":"","supportUrl":"","listing":{"blurb":"","imageUrl":""},"provider":{"name":""}}`
Expect(metadata).To(MarshalToJSON(json))
})
})
})
Describe("ServiceMetadataListing", func() {
Describe("JSON encoding", func() {
It("uses the correct keys", func() {
listing := brokerapi.ServiceMetadataListing{
Blurb: "Blurb",
ImageUrl: "foo",
}
json := `{"blurb":"Blurb","imageUrl":"foo"}`
Expect(listing).To(MarshalToJSON(json))
})
})
})
Describe("ServiceMetadataProvider", func() {
Describe("JSON encoding", func() {
It("uses the correct keys", func() {
provider := brokerapi.ServiceMetadataProvider{
Name: "Pivotal",
}
json := `{"name":"Pivotal"}`
Expect(provider).To(MarshalToJSON(json))
})
})
})
})