diff --git a/pkg/printers/internalversion/describe_test.go b/pkg/printers/internalversion/describe_test.go index dc0775055e2..eea94efcba1 100644 --- a/pkg/printers/internalversion/describe_test.go +++ b/pkg/printers/internalversion/describe_test.go @@ -1020,6 +1020,7 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) { block := api.PersistentVolumeBlock file := api.PersistentVolumeFilesystem goldClassName := "gold" + now := time.Now() testCases := []struct { name string pvc *api.PersistentVolumeClaim @@ -1070,6 +1071,103 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) { }, expectedElements: []string{"VolumeMode", "Block"}, }, + // Tests for Status.Condition. + { + name: "condition-type", + pvc: &api.PersistentVolumeClaim{ + ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"}, + Spec: api.PersistentVolumeClaimSpec{ + VolumeName: "volume4", + StorageClassName: &goldClassName, + }, + Status: api.PersistentVolumeClaimStatus{ + Conditions: []api.PersistentVolumeClaimCondition{ + {Type: api.PersistentVolumeClaimResizing}, + }, + }, + }, + expectedElements: []string{"Conditions", "Type", "Resizing"}, + }, + { + name: "condition-status", + pvc: &api.PersistentVolumeClaim{ + ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"}, + Spec: api.PersistentVolumeClaimSpec{ + VolumeName: "volume5", + StorageClassName: &goldClassName, + }, + Status: api.PersistentVolumeClaimStatus{ + Conditions: []api.PersistentVolumeClaimCondition{ + {Status: api.ConditionTrue}, + }, + }, + }, + expectedElements: []string{"Conditions", "Status", "True"}, + }, + { + name: "condition-last-probe-time", + pvc: &api.PersistentVolumeClaim{ + ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"}, + Spec: api.PersistentVolumeClaimSpec{ + VolumeName: "volume6", + StorageClassName: &goldClassName, + }, + Status: api.PersistentVolumeClaimStatus{ + Conditions: []api.PersistentVolumeClaimCondition{ + {LastProbeTime: metav1.Time{Time: now}}, + }, + }, + }, + expectedElements: []string{"Conditions", "LastProbeTime", now.Format(time.RFC1123Z)}, + }, + { + name: "condition-last-transition-time", + pvc: &api.PersistentVolumeClaim{ + ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"}, + Spec: api.PersistentVolumeClaimSpec{ + VolumeName: "volume7", + StorageClassName: &goldClassName, + }, + Status: api.PersistentVolumeClaimStatus{ + Conditions: []api.PersistentVolumeClaimCondition{ + {LastTransitionTime: metav1.Time{Time: now}}, + }, + }, + }, + expectedElements: []string{"Conditions", "LastTransitionTime", now.Format(time.RFC1123Z)}, + }, + { + name: "condition-reason", + pvc: &api.PersistentVolumeClaim{ + ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"}, + Spec: api.PersistentVolumeClaimSpec{ + VolumeName: "volume8", + StorageClassName: &goldClassName, + }, + Status: api.PersistentVolumeClaimStatus{ + Conditions: []api.PersistentVolumeClaimCondition{ + {Reason: "OfflineResize"}, + }, + }, + }, + expectedElements: []string{"Conditions", "Reason", "OfflineResize"}, + }, + { + name: "condition-message", + pvc: &api.PersistentVolumeClaim{ + ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"}, + Spec: api.PersistentVolumeClaimSpec{ + VolumeName: "volume9", + StorageClassName: &goldClassName, + }, + Status: api.PersistentVolumeClaimStatus{ + Conditions: []api.PersistentVolumeClaimCondition{ + {Message: "User request resize"}, + }, + }, + }, + expectedElements: []string{"Conditions", "Message", "User request resize"}, + }, } for _, test := range testCases {