From a73f793e8e3b15f172d36d0c65d67dc4c0ab77a2 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Mon, 19 Nov 2018 15:19:55 +0100 Subject: [PATCH] Add unit test for metadata modification --- .../storage/volumeattachment/strategy_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/registry/storage/volumeattachment/strategy_test.go b/pkg/registry/storage/volumeattachment/strategy_test.go index e2ec6b4b708..eadde7ccc1c 100644 --- a/pkg/registry/storage/volumeattachment/strategy_test.go +++ b/pkg/registry/storage/volumeattachment/strategy_test.go @@ -113,9 +113,18 @@ func TestVolumeAttachmentStatusStrategy(t *testing.T) { t.Errorf("unexpected objects differerence after modifying status: %v", diff.ObjectDiff(statusVolumeAttachment, expectedVolumeAttachment)) } - // modifying spec should be dropped + // spec and metadata modifications should be dropped newVolumeAttachment := volumeAttachment.DeepCopy() newVolumeAttachment.Spec.NodeName = "valid-node-2" + newVolumeAttachment.Labels = map[string]string{"foo": "bar"} + newVolumeAttachment.Annotations = map[string]string{"foo": "baz"} + newVolumeAttachment.OwnerReferences = []metav1.OwnerReference{ + { + APIVersion: "v1", + Kind: "Pod", + Name: "Foo", + }, + } StatusStrategy.PrepareForUpdate(ctx, newVolumeAttachment, volumeAttachment) if !apiequality.Semantic.DeepEqual(newVolumeAttachment, volumeAttachment) {