mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-08-08 06:50:44 +00:00
Fix fuzzer for defaults
This commit is contained in:
@@ -100,6 +100,10 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||
obj.Spec.SELinuxMount = new(bool)
|
||||
*(obj.Spec.SELinuxMount) = false
|
||||
}
|
||||
if obj.Spec.PreventPodSchedulingIfMissing == nil {
|
||||
obj.Spec.PreventPodSchedulingIfMissing = new(bool)
|
||||
*(obj.Spec.PreventPodSchedulingIfMissing) = false
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2309,7 +2309,7 @@ func TestCSIDriverValidationSELinuxMountEnabledDisabled(t *testing.T) {
|
||||
}, {
|
||||
name: "feature enabled, non-nil value",
|
||||
featureEnabled: true,
|
||||
seLinuxMountValue: ptr.To(true),
|
||||
seLinuxMountValue: new(true),
|
||||
expectError: false,
|
||||
}, {
|
||||
name: "feature disabled, nil value",
|
||||
@@ -2319,7 +2319,7 @@ func TestCSIDriverValidationSELinuxMountEnabledDisabled(t *testing.T) {
|
||||
}, {
|
||||
name: "feature disabled, non-nil value",
|
||||
featureEnabled: false,
|
||||
seLinuxMountValue: ptr.To(true),
|
||||
seLinuxMountValue: new(true),
|
||||
expectError: false,
|
||||
}}
|
||||
for _, test := range tests {
|
||||
@@ -2331,10 +2331,10 @@ func TestCSIDriverValidationSELinuxMountEnabledDisabled(t *testing.T) {
|
||||
csiDriver := &storage.CSIDriver{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
|
||||
Spec: storage.CSIDriverSpec{
|
||||
AttachRequired: ptr.To(true),
|
||||
PodInfoOnMount: ptr.To(true),
|
||||
RequiresRepublish: ptr.To(true),
|
||||
StorageCapacity: ptr.To(true),
|
||||
AttachRequired: new(true),
|
||||
PodInfoOnMount: new(true),
|
||||
RequiresRepublish: new(true),
|
||||
StorageCapacity: new(true),
|
||||
SELinuxMount: test.seLinuxMountValue,
|
||||
PreventPodSchedulingIfMissing: new(false),
|
||||
},
|
||||
@@ -2365,18 +2365,18 @@ func TestCSIDriverValidationSELinuxMountEnabledDisabled(t *testing.T) {
|
||||
name: "feature enabled, nil->set",
|
||||
featureEnabled: true,
|
||||
oldValue: nil,
|
||||
newValue: ptr.To(true),
|
||||
newValue: new(true),
|
||||
expectError: false,
|
||||
}, {
|
||||
name: "feature enabled, set->set",
|
||||
featureEnabled: true,
|
||||
oldValue: ptr.To(true),
|
||||
newValue: ptr.To(true),
|
||||
oldValue: new(true),
|
||||
newValue: new(true),
|
||||
expectError: false,
|
||||
}, {
|
||||
name: "feature enabled, set->nil",
|
||||
featureEnabled: true,
|
||||
oldValue: ptr.To(true),
|
||||
oldValue: new(true),
|
||||
newValue: nil,
|
||||
expectError: true, // populated by defaulting and required when feature is enabled
|
||||
}, {
|
||||
@@ -2389,18 +2389,18 @@ func TestCSIDriverValidationSELinuxMountEnabledDisabled(t *testing.T) {
|
||||
name: "feature disabled, nil->set",
|
||||
featureEnabled: false,
|
||||
oldValue: nil,
|
||||
newValue: ptr.To(true),
|
||||
newValue: new(true),
|
||||
expectError: false,
|
||||
}, {
|
||||
name: "feature disabled, set->set",
|
||||
featureEnabled: false,
|
||||
oldValue: ptr.To(true),
|
||||
newValue: ptr.To(true),
|
||||
oldValue: new(true),
|
||||
newValue: new(true),
|
||||
expectError: false,
|
||||
}, {
|
||||
name: "feature disabled, set->nil",
|
||||
featureEnabled: false,
|
||||
oldValue: ptr.To(true),
|
||||
oldValue: new(true),
|
||||
newValue: nil,
|
||||
expectError: false,
|
||||
}}
|
||||
@@ -2413,10 +2413,10 @@ func TestCSIDriverValidationSELinuxMountEnabledDisabled(t *testing.T) {
|
||||
oldCSIDriver := &storage.CSIDriver{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||
Spec: storage.CSIDriverSpec{
|
||||
AttachRequired: ptr.To(true),
|
||||
PodInfoOnMount: ptr.To(true),
|
||||
RequiresRepublish: ptr.To(true),
|
||||
StorageCapacity: ptr.To(true),
|
||||
AttachRequired: new(true),
|
||||
PodInfoOnMount: new(true),
|
||||
RequiresRepublish: new(true),
|
||||
StorageCapacity: new(true),
|
||||
SELinuxMount: test.oldValue,
|
||||
PreventPodSchedulingIfMissing: new(false),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user