forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_plan_resource_test.go
116 lines (113 loc) · 2.52 KB
/
service_plan_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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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 plan resource", func() {
DescribeTable(
"Unmarshaling",
func(servicePlan ServicePlan, serialized string) {
var parsed ServicePlan
Expect(json.Unmarshal([]byte(serialized), &parsed)).NotTo(HaveOccurred())
Expect(parsed).To(Equal(servicePlan))
},
Entry(
"basic",
ServicePlan{
GUID: "fake-service-plan-guid",
Name: "fake-service-plan-name",
ServiceOfferingGUID: "fake-service-offering-guid",
},
`{
"guid": "fake-service-plan-guid",
"name": "fake-service-plan-name",
"relationships": {
"service_offering": {
"data": {
"guid": "fake-service-offering-guid"
}
}
}
}`,
),
Entry(
"detailed",
ServicePlan{
GUID: "fake-service-plan-guid",
Name: "fake-service-plan-name",
ServiceOfferingGUID: "fake-service-offering-guid",
Description: "fake-description",
Available: true,
VisibilityType: "public",
Free: true,
Costs: []ServicePlanCost{
{
Amount: 12.5,
Currency: "USD",
Unit: "month",
},
{
Amount: 3.25,
Currency: "EUR",
Unit: "day",
},
},
SpaceGUID: "fake-space-guid",
MaintenanceInfoDescription: "cool upgrade",
MaintenanceInfoVersion: "1.2.3",
Metadata: &Metadata{
Labels: map[string]types.NullString{
"foo": types.NewNullString("bar"),
"baz": types.NewNullString(),
},
},
},
`{
"guid": "fake-service-plan-guid",
"name": "fake-service-plan-name",
"description": "fake-description",
"available": true,
"visibility_type": "public",
"free": true,
"costs": [
{
"amount": 12.5,
"currency": "USD",
"unit": "month"
},
{
"amount": 3.25,
"currency": "EUR",
"unit": "day"
}
],
"maintenance_info": {
"description": "cool upgrade",
"version": "1.2.3"
},
"metadata": {
"labels": {
"foo": "bar",
"baz": null
}
},
"relationships": {
"service_offering": {
"data": {
"guid": "fake-service-offering-guid"
}
},
"space": {
"data": {
"guid": "fake-space-guid"
}
}
}
}`,
),
)
})