From bab6b5a66e588b610ae4b10561b5cb581667d62e Mon Sep 17 00:00:00 2001 From: Scott Creeley Date: Thu, 1 Sep 2016 15:12:13 -0400 Subject: [PATCH] Add unit test for bad ReclaimPolicy and valid ReclaimPolicy in /pkg/api/validation_test.go --- pkg/api/validation/validation_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index 5032120b3e1..eda28cc940d 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -477,6 +477,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{ @@ -489,6 +502,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{