forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_offering_resource_test.go
97 lines (94 loc) · 2.58 KB
/
service_offering_resource_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
package resources_test
import (
"encoding/json"
. "code.cloudfoundry.org/cli/resources"
"code.cloudfoundry.org/cli/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
)
var _ = Describe("service offering resource", func() {
DescribeTable(
"Unmarshaling",
func(serviceInstance ServiceOffering, serialized string) {
var parsed ServiceOffering
Expect(json.Unmarshal([]byte(serialized), &parsed)).NotTo(HaveOccurred())
Expect(parsed).To(Equal(serviceInstance))
},
Entry("name", ServiceOffering{Name: "fake-name"}, `{"name": "fake-name"}`),
Entry("guid", ServiceOffering{GUID: "fake-guid"}, `{"guid": "fake-guid"}`),
Entry("shareable", ServiceOffering{AllowsInstanceSharing: true}, `{"shareable": true}`),
Entry("description", ServiceOffering{Description: "once upon a time"}, `{"description": "once upon a time"}`),
Entry("documentation_url", ServiceOffering{DocumentationURL: "https://docs.com"}, `{"documentation_url": "https://docs.com"}`),
Entry("tags", ServiceOffering{Tags: types.NewOptionalStringSlice("foo", "bar")}, `{"tags": ["foo", "bar"]}`),
Entry("tags empty", ServiceOffering{Tags: types.NewOptionalStringSlice()}, `{"tags": []}`),
Entry(
"service broker guid",
ServiceOffering{ServiceBrokerGUID: "fake-service-broker-guid"},
`{
"relationships": {
"service_broker": {
"data": {
"guid": "fake-service-broker-guid"
}
}
}
}`,
),
Entry(
"metadata",
ServiceOffering{
Metadata: &Metadata{
Labels: map[string]types.NullString{
"foo": types.NewNullString("bar"),
"baz": types.NewNullString(),
},
},
},
`{
"metadata": {
"labels": {
"foo": "bar",
"baz": null
}
}
}`,
),
Entry(
"everything",
ServiceOffering{
Name: "fake-name",
GUID: "fake-guid",
Description: "once upon a time",
DocumentationURL: "https://docs.com",
ServiceBrokerGUID: "fake-service-broker-guid",
Metadata: &Metadata{
Labels: map[string]types.NullString{
"foo": types.NewNullString("bar"),
"baz": types.NewNullString(),
},
},
},
`{
"name": "fake-name",
"guid": "fake-guid",
"url": "https://fake-url.com",
"description": "once upon a time",
"documentation_url": "https://docs.com",
"metadata": {
"labels": {
"foo": "bar",
"baz": null
}
},
"relationships": {
"service_broker": {
"data": {
"guid": "fake-service-broker-guid"
}
}
}
}`,
),
)
})