Skip to content

Commit fb77413

Browse files
committed
test: Add some un-documented variants to the NormalEnum
1 parent 13db30c commit fb77413

File tree

1 file changed

+112
-104
lines changed

1 file changed

+112
-104
lines changed

kube-derive/tests/crd_complex_enum_tests.rs

Lines changed: 112 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ enum NormalEnum {
1212
A,
1313
/// Second variant
1414
B,
15+
16+
// No doc-comments on these variants
17+
C,
18+
D,
1519
}
1620

1721
/// An untagged enum with a nested enum inside
@@ -89,61 +93,63 @@ fn normal_enum() {
8993
assert_json_eq!(
9094
NormalEnumTest::crd(),
9195
json!(
92-
{
93-
"apiVersion": "apiextensions.k8s.io/v1",
94-
"kind": "CustomResourceDefinition",
95-
"metadata": {
96-
"name": "normalenumtests.clux.dev"
96+
{
97+
"apiVersion": "apiextensions.k8s.io/v1",
98+
"kind": "CustomResourceDefinition",
99+
"metadata": {
100+
"name": "normalenumtests.clux.dev"
101+
},
102+
"spec": {
103+
"group": "clux.dev",
104+
"names": {
105+
"categories": [],
106+
"kind": "NormalEnumTest",
107+
"plural": "normalenumtests",
108+
"shortNames": [],
109+
"singular": "normalenumtest"
97110
},
98-
"spec": {
99-
"group": "clux.dev",
100-
"names": {
101-
"categories": [],
102-
"kind": "NormalEnumTest",
103-
"plural": "normalenumtests",
104-
"shortNames": [],
105-
"singular": "normalenumtest"
106-
},
107-
"scope": "Cluster",
108-
"versions": [
109-
{
110-
"additionalPrinterColumns": [],
111-
"name": "v1",
112-
"schema": {
113-
"openAPIV3Schema": {
114-
"description": "Auto-generated derived type for NormalEnumTestSpec via `CustomResource`",
115-
"properties": {
116-
"spec": {
117-
"properties": {
118-
"foo": {
119-
"description": "A very simple enum with empty variants",
120-
"enum": [
121-
"A",
122-
"B"
123-
],
124-
"type": "string"
125-
}
126-
},
127-
"required": [
128-
"foo"
129-
],
130-
"type": "object"
131-
}
132-
},
133-
"required": [
134-
"spec"
135-
],
136-
"title": "NormalEnumTest",
137-
"type": "object"
138-
}
139-
},
140-
"served": true,
141-
"storage": true,
142-
"subresources": {}
143-
}
144-
]
145-
}
111+
"scope": "Cluster",
112+
"versions": [
113+
{
114+
"additionalPrinterColumns": [],
115+
"name": "v1",
116+
"schema": {
117+
"openAPIV3Schema": {
118+
"description": "Auto-generated derived type for NormalEnumTestSpec via `CustomResource`",
119+
"properties": {
120+
"spec": {
121+
"properties": {
122+
"foo": {
123+
"description": "A very simple enum with empty variants",
124+
"enum": [
125+
"C",
126+
"D",
127+
"A",
128+
"B"
129+
],
130+
"type": "string"
131+
}
132+
},
133+
"required": [
134+
"foo"
135+
],
136+
"type": "object"
137+
}
138+
},
139+
"required": [
140+
"spec"
141+
],
142+
"title": "NormalEnumTest",
143+
"type": "object"
144+
}
145+
},
146+
"served": true,
147+
"storage": true,
148+
"subresources": {}
149+
}
150+
]
146151
}
152+
}
147153
)
148154
);
149155
}
@@ -153,59 +159,61 @@ fn optional_enum() {
153159
assert_json_eq!(
154160
OptionalEnumTest::crd(),
155161
json!(
156-
{
157-
"apiVersion": "apiextensions.k8s.io/v1",
158-
"kind": "CustomResourceDefinition",
159-
"metadata": {
160-
"name": "optionalenumtests.clux.dev"
162+
{
163+
"apiVersion": "apiextensions.k8s.io/v1",
164+
"kind": "CustomResourceDefinition",
165+
"metadata": {
166+
"name": "optionalenumtests.clux.dev"
167+
},
168+
"spec": {
169+
"group": "clux.dev",
170+
"names": {
171+
"categories": [],
172+
"kind": "OptionalEnumTest",
173+
"plural": "optionalenumtests",
174+
"shortNames": [],
175+
"singular": "optionalenumtest"
161176
},
162-
"spec": {
163-
"group": "clux.dev",
164-
"names": {
165-
"categories": [],
166-
"kind": "OptionalEnumTest",
167-
"plural": "optionalenumtests",
168-
"shortNames": [],
169-
"singular": "optionalenumtest"
170-
},
171-
"scope": "Cluster",
172-
"versions": [
173-
{
174-
"additionalPrinterColumns": [],
175-
"name": "v1",
176-
"schema": {
177-
"openAPIV3Schema": {
178-
"description": "Auto-generated derived type for OptionalEnumTestSpec via `CustomResource`",
179-
"properties": {
180-
"spec": {
181-
"properties": {
182-
"foo": {
183-
"description": "A very simple enum with empty variants",
184-
"enum": [
185-
"A",
186-
"B"
187-
],
188-
"nullable": true,
189-
"type": "string"
190-
}
191-
},
192-
"type": "object"
193-
}
194-
},
195-
"required": [
196-
"spec"
197-
],
198-
"title": "OptionalEnumTest",
199-
"type": "object"
200-
}
201-
},
202-
"served": true,
203-
"storage": true,
204-
"subresources": {}
205-
}
206-
]
207-
}
177+
"scope": "Cluster",
178+
"versions": [
179+
{
180+
"additionalPrinterColumns": [],
181+
"name": "v1",
182+
"schema": {
183+
"openAPIV3Schema": {
184+
"description": "Auto-generated derived type for OptionalEnumTestSpec via `CustomResource`",
185+
"properties": {
186+
"spec": {
187+
"properties": {
188+
"foo": {
189+
"description": "A very simple enum with empty variants",
190+
"enum": [
191+
"C",
192+
"D",
193+
"A",
194+
"B"
195+
],
196+
"nullable": true,
197+
"type": "string"
198+
}
199+
},
200+
"type": "object"
201+
}
202+
},
203+
"required": [
204+
"spec"
205+
],
206+
"title": "OptionalEnumTest",
207+
"type": "object"
208+
}
209+
},
210+
"served": true,
211+
"storage": true,
212+
"subresources": {}
213+
}
214+
]
208215
}
216+
}
209217
)
210218
);
211219
}

0 commit comments

Comments
 (0)