Skip to content

Commit 2e0a7aa

Browse files
committed
chore: add expected results to complex enum tests
1 parent 39df989 commit 2e0a7aa

File tree

1 file changed

+204
-2
lines changed

1 file changed

+204
-2
lines changed

kube-derive/tests/crd_complex_enum_tests.rs

Lines changed: 204 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,215 @@ fn optional_enum_without_descriptions() {
425425

426426
#[test]
427427
fn complex_enum() {
428-
assert_json_eq!(ComplexEnumTest::crd(), json!(42));
428+
assert_json_eq!(
429+
ComplexEnumTest::crd(),
430+
json!(
431+
{
432+
"apiVersion": "apiextensions.k8s.io/v1",
433+
"kind": "CustomResourceDefinition",
434+
"metadata": {
435+
"name": "complexenumtests.clux.dev"
436+
},
437+
"spec": {
438+
"group": "clux.dev",
439+
"names": {
440+
"categories": [],
441+
"kind": "ComplexEnumTest",
442+
"plural": "complexenumtests",
443+
"shortNames": [],
444+
"singular": "complexenumtest"
445+
},
446+
"scope": "Cluster",
447+
"versions": [
448+
{
449+
"additionalPrinterColumns": [],
450+
"name": "v1",
451+
"schema": {
452+
"openAPIV3Schema": {
453+
"description": "Auto-generated derived type for ComplexEnumTestSpec via `CustomResource`",
454+
"properties": {
455+
"spec": {
456+
"properties": {
457+
"foo": {
458+
"description": "A complex enum with tuple and struct variants",
459+
"oneOf": [
460+
{
461+
"required": [
462+
"Normal"
463+
]
464+
},
465+
{
466+
"required": [
467+
"Hardcore"
468+
]
469+
}
470+
],
471+
"properties": {
472+
"Hardcore": {
473+
"description": "Documentation on the Hardcore variant",
474+
"properties": {
475+
"core": {
476+
"description": "A very simple enum with unit variants",
477+
"enum": [
478+
"C",
479+
"D",
480+
"A",
481+
"B"
482+
],
483+
"type": "string"
484+
},
485+
"hard": {
486+
"type": "string"
487+
}
488+
},
489+
"required": [
490+
"core",
491+
"hard"
492+
],
493+
"type": "object"
494+
},
495+
"Normal": {
496+
"description": "Override documentation on the Normal variant",
497+
"enum": [
498+
"C",
499+
"D",
500+
"A",
501+
"B"
502+
],
503+
"type": "string"
504+
}
505+
},
506+
"type": "object"
507+
}
508+
},
509+
"required": [
510+
"foo"
511+
],
512+
"type": "object"
513+
}
514+
},
515+
"required": [
516+
"spec"
517+
],
518+
"title": "ComplexEnumTest",
519+
"type": "object"
520+
}
521+
},
522+
"served": true,
523+
"storage": true,
524+
"subresources": {}
525+
}
526+
]
527+
}
528+
}
529+
)
530+
);
429531
}
430532

431533

432534
#[test]
433535
fn optional_complex_enum() {
434-
assert_json_eq!(OptionalComplexEnumTest::crd(), json!(42));
536+
assert_json_eq!(
537+
OptionalComplexEnumTest::crd(),
538+
json!(
539+
{
540+
"apiVersion": "apiextensions.k8s.io/v1",
541+
"kind": "CustomResourceDefinition",
542+
"metadata": {
543+
"name": "optionalcomplexenumtests.clux.dev"
544+
},
545+
"spec": {
546+
"group": "clux.dev",
547+
"names": {
548+
"categories": [],
549+
"kind": "OptionalComplexEnumTest",
550+
"plural": "optionalcomplexenumtests",
551+
"shortNames": [],
552+
"singular": "optionalcomplexenumtest"
553+
},
554+
"scope": "Cluster",
555+
"versions": [
556+
{
557+
"additionalPrinterColumns": [],
558+
"name": "v1",
559+
"schema": {
560+
"openAPIV3Schema": {
561+
"description": "Auto-generated derived type for OptionalComplexEnumTestSpec via `CustomResource`",
562+
"properties": {
563+
"spec": {
564+
"properties": {
565+
"foo": {
566+
"description": "A complex enum with tuple and struct variants",
567+
"nullable": true,
568+
"oneOf": [
569+
{
570+
"required": [
571+
"Normal"
572+
]
573+
},
574+
{
575+
"required": [
576+
"Hardcore"
577+
]
578+
}
579+
],
580+
"properties": {
581+
"Hardcore": {
582+
"description": "Documentation on the Hardcore variant",
583+
"properties": {
584+
"core": {
585+
"description": "A very simple enum with unit variants",
586+
"enum": [
587+
"C",
588+
"D",
589+
"A",
590+
"B"
591+
],
592+
"type": "string"
593+
},
594+
"hard": {
595+
"type": "string"
596+
}
597+
},
598+
"required": [
599+
"core",
600+
"hard"
601+
],
602+
"type": "object"
603+
},
604+
"Normal": {
605+
"description": "Override documentation on the Normal variant",
606+
"enum": [
607+
"C",
608+
"D",
609+
"A",
610+
"B"
611+
],
612+
"type": "string"
613+
}
614+
},
615+
"type": "object"
616+
}
617+
},
618+
"type": "object"
619+
}
620+
},
621+
"required": [
622+
"spec"
623+
],
624+
"title": "OptionalComplexEnumTest",
625+
"type": "object"
626+
}
627+
},
628+
"served": true,
629+
"storage": true,
630+
"subresources": {}
631+
}
632+
]
633+
}
634+
}
635+
)
636+
);
435637
}
436638

437639
#[test]

0 commit comments

Comments
 (0)