From 74399c78e79f59cdac36deac19e35c6ea7c0b77d Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Fri, 12 Jun 2026 10:05:25 +0000 Subject: internal/mru: Test that sync places new keys first --- internal/mru/order_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/mru/order_test.go b/internal/mru/order_test.go index 8b667e77..bf0d4f2e 100644 --- a/internal/mru/order_test.go +++ b/internal/mru/order_test.go @@ -58,6 +58,22 @@ func TestSyncDropsAbsentAndKeepsSurvivorOrder(t *testing.T) { } } +func TestSyncPlacesNewKeysFirst(t *testing.T) { + t.Parallel() + + order := mru.New[string]() + order.Sync(set("a", "b")) + + order.Touch("a") + order.Touch("b") + + order.Sync(set("a", "b", "z")) + + if got, want := order.Keys(), []string{"z", "b", "a"}; !slices.Equal(got, want) { + t.Fatalf("after Sync, order = %v, want %v", got, want) + } +} + func TestTouchAbsentIsNoOp(t *testing.T) { t.Parallel() -- cgit v1.3.1-10-gc9f91