-
Notifications
You must be signed in to change notification settings - Fork 944
/
Copy pathshared_to_spaces_resource_test.go
130 lines (125 loc) · 3.14 KB
/
shared_to_spaces_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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package resources_test
import (
"encoding/json"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant"
. "code.cloudfoundry.org/cli/resources"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("shared to spaces resource", func() {
DescribeTable(
"Unmarshaling",
func(sharedToSpaces SharedToSpacesListWrapper, serialized string) {
var parsed SharedToSpacesListWrapper
Expect(json.Unmarshal([]byte(serialized), &parsed)).NotTo(HaveOccurred())
Expect(parsed).To(Equal(sharedToSpaces))
},
Entry("SharedToSpaceGUIDs", SharedToSpacesListWrapper{SharedToSpaceGUIDs: []string{"fake-space-guid", "other-fake-space-guid"}}, `{"data": [{"guid": "fake-space-guid"}, {"guid": "other-fake-space-guid"}]}`),
Entry("Spaces", SharedToSpacesListWrapper{
Spaces: []Space{
{
GUID: "fake-space-guid",
Name: "fake-space-name",
Relationships: map[constant.RelationshipType]Relationship{
"organization": Relationship{
GUID: "some-org-guid",
},
},
},
},
}, `{
"included": {
"spaces": [
{
"name": "fake-space-name",
"guid": "fake-space-guid",
"relationships": {
"organization": {
"data": {
"guid": "some-org-guid"
}
}
}
}
]
}
}`),
Entry("Organizations", SharedToSpacesListWrapper{
Organizations: []Organization{
{
GUID: "fake-org-guid",
Name: "fake-org-name",
},
},
}, `{
"included": {
"organizations": [
{
"name": "fake-org-name",
"guid": "fake-org-guid"
}
]
}
}`),
Entry(
"everything",
SharedToSpacesListWrapper{
SharedToSpaceGUIDs: []string{"fake-space-guid", "other-fake-space-guid"},
Spaces: []Space{
{
GUID: "fake-space-guid",
Name: "fake-space-name",
Relationships: map[constant.RelationshipType]Relationship{"organization": Relationship{GUID: "fake-org-guid"}}},
{
GUID: "other-fake-space-guid",
Name: "other-fake-space-name",
Relationships: map[constant.RelationshipType]Relationship{"organization": Relationship{GUID: "fake-org-guid"}}}},
Organizations: []Organization{
{
GUID: "fake-org-guid",
Name: "fake-org-name",
},
}},
`{
"data": [{"guid":"fake-space-guid"},{"guid":"other-fake-space-guid"}],
"links": {
"self": {
"href": "https://some-url/v3/service_instances/7915bc51-8203-4758-b0e2-f77bfcdc38cb/relationships/shared_spaces"
}
},
"included": {
"spaces": [
{
"name": "fake-space-name",
"guid": "fake-space-guid",
"relationships": {
"organization": {
"data": {
"guid": "fake-org-guid"
}
}
}
},
{
"name": "other-fake-space-name",
"guid": "other-fake-space-guid",
"relationships": {
"organization": {
"data": {
"guid": "fake-org-guid"
}
}
}
}
],
"organizations": [
{
"name": "fake-org-name",
"guid": "fake-org-guid"
}
]
}
}`,
),
)
})