mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +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"},
|
||||
"preserving": {"unspecified": "bar"}
|
||||
},
|
||||
"preservingAdditionalProperties": {
|
||||
"preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": {
|
||||
"foo": {
|
||||
"specified": {"unspecified":"bar"},
|
||||
"unspecified": "bar"
|
||||
}
|
||||
},
|
||||
"preservingAdditionalPropertiesKeyPruneValues": {
|
||||
"foo": {
|
||||
"specified": {"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},
|
||||
Generic: structuralschema.Generic{
|
||||
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: `
|
||||
{
|
||||
@ -154,7 +174,12 @@ func TestPrune(t *testing.T) {
|
||||
"pruning": {},
|
||||
"preserving": {"unspecified": "bar"}
|
||||
},
|
||||
"preservingAdditionalProperties": {
|
||||
"preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": {
|
||||
"foo": {
|
||||
"specified": {}
|
||||
}
|
||||
},
|
||||
"preservingAdditionalPropertiesKeyPruneValues": {
|
||||
"foo": {
|
||||
"specified": {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user