diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index 48bc3575f27..9d11bea90fa 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -516,6 +516,19 @@ func TestValidatePersistentVolumes(t *testing.T) { }, }), }, + "good-volume-with-retain-policy": { + isExpectedFailure: false, + volume: testVolume("foo", "", api.PersistentVolumeSpec{ + Capacity: api.ResourceList{ + api.ResourceName(api.ResourceStorage): resource.MustParse("10G"), + }, + AccessModes: []api.PersistentVolumeAccessMode{api.ReadWriteOnce}, + PersistentVolumeSource: api.PersistentVolumeSource{ + HostPath: &api.HostPathVolumeSource{Path: "/foo"}, + }, + PersistentVolumeReclaimPolicy: api.PersistentVolumeReclaimRetain, + }), + }, "invalid-accessmode": { isExpectedFailure: true, volume: testVolume("foo", "", api.PersistentVolumeSpec{ @@ -528,6 +541,19 @@ func TestValidatePersistentVolumes(t *testing.T) { }, }), }, + "invalid-reclaimpolicy": { + isExpectedFailure: true, + volume: testVolume("foo", "", api.PersistentVolumeSpec{ + Capacity: api.ResourceList{ + api.ResourceName(api.ResourceStorage): resource.MustParse("10G"), + }, + AccessModes: []api.PersistentVolumeAccessMode{api.ReadWriteOnce}, + PersistentVolumeSource: api.PersistentVolumeSource{ + HostPath: &api.HostPathVolumeSource{Path: "/foo"}, + }, + PersistentVolumeReclaimPolicy: "fakeReclaimPolicy", + }), + }, "unexpected-namespace": { isExpectedFailure: true, volume: testVolume("foo", "unexpected-namespace", api.PersistentVolumeSpec{