diff --git a/container/mts/meta/meta_test.go b/container/mts/meta/meta_test.go index 87c52461..6002b55c 100644 --- a/container/mts/meta/meta_test.go +++ b/container/mts/meta/meta_test.go @@ -251,3 +251,45 @@ func TestEncodeAsString(t *testing.T) { t.Errorf("Did not get expected out. \nGot : %v, \nWant: %v or %v\n", got, want1, want2) } } + +// TestDeleteOrder checks that the order of keys is correct after a deletion. +func TestDeleteOrder(t *testing.T) { + tests := []struct { + delKey string + want []string + }{ + { + "key1", + []string{"key2", "key3", "key4"}, + }, + { + "key2", + []string{"key1", "key3", "key4"}, + }, + { + "key3", + []string{"key1", "key2", "key4"}, + }, + { + "key4", + []string{"key1", "key2", "key3"}, + }, + } + + for _, test := range tests { + t.Logf("deleting %s", test.delKey) + meta := NewWith([][2]string{ + {"key1", "val1"}, + {"key2", "val2"}, + {"key3", "val3"}, + {"key4", "val4"}, + }) + meta.Delete(test.delKey) + + got := meta.order + want := test.want + if !reflect.DeepEqual(got, want) { + t.Errorf("Did not get expected out. \nGot: %v, \nWant: %v\n", got, want) + } + } +}