mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 03:03:59 +00:00
apiextensions: add unit test for x-kubernetes-preserve-unknown-fields with additionalProperties
This commit is contained in:
parent
5d000b1339
commit
a03330fbeb
@ -85,7 +85,13 @@ func TestPrune(t *testing.T) {
|
|||||||
"pruning": {"unspecified": "bar"},
|
"pruning": {"unspecified": "bar"},
|
||||||
"preserving": {"unspecified": "bar"}
|
"preserving": {"unspecified": "bar"}
|
||||||
},
|
},
|
||||||
"preservingAdditionalProperties": {
|
"preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": {
|
||||||
|
"foo": {
|
||||||
|
"specified": {"unspecified":"bar"},
|
||||||
|
"unspecified": "bar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"preservingAdditionalPropertiesKeyPruneValues": {
|
||||||
"foo": {
|
"foo": {
|
||||||
"specified": {"unspecified":"bar"},
|
"specified": {"unspecified":"bar"},
|
||||||
"unspecified": "bar"
|
"unspecified": "bar"
|
||||||
@ -123,7 +129,8 @@ func TestPrune(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"preservingAdditionalProperties": {
|
"preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": {
|
||||||
|
// this x-kubernetes-preserve-unknown-fields is not inherited by the schema inside of additionalProperties
|
||||||
Extensions: structuralschema.Extensions{XPreserveUnknownFields: true},
|
Extensions: structuralschema.Extensions{XPreserveUnknownFields: true},
|
||||||
Generic: structuralschema.Generic{
|
Generic: structuralschema.Generic{
|
||||||
Type: "object",
|
Type: "object",
|
||||||
@ -137,6 +144,19 @@ func TestPrune(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"preservingAdditionalPropertiesKeyPruneValues": {
|
||||||
|
Generic: structuralschema.Generic{
|
||||||
|
Type: "object",
|
||||||
|
AdditionalProperties: &structuralschema.StructuralOrBool{
|
||||||
|
Structural: &structuralschema.Structural{
|
||||||
|
Generic: structuralschema.Generic{Type: "object"},
|
||||||
|
Properties: map[string]structuralschema.Structural{
|
||||||
|
"specified": {Generic: structuralschema.Generic{Type: "object"}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}, expected: `
|
}, expected: `
|
||||||
{
|
{
|
||||||
@ -154,7 +174,12 @@ func TestPrune(t *testing.T) {
|
|||||||
"pruning": {},
|
"pruning": {},
|
||||||
"preserving": {"unspecified": "bar"}
|
"preserving": {"unspecified": "bar"}
|
||||||
},
|
},
|
||||||
"preservingAdditionalProperties": {
|
"preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": {
|
||||||
|
"foo": {
|
||||||
|
"specified": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"preservingAdditionalPropertiesKeyPruneValues": {
|
||||||
"foo": {
|
"foo": {
|
||||||
"specified": {}
|
"specified": {}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user