aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-06-12 10:05:25 +0000
committerGravatar Runxi Yu2026-06-12 10:05:25 +0000
commit74399c78e79f59cdac36deac19e35c6ea7c0b77d (patch)
treecb00b0597b86fda7e36dc221a4bdd9a03899dc0a
parentinternal/mru: Append keys before the survivors (diff)
internal/mru: Test that sync places new keys first
-rw-r--r--internal/mru/order_test.go16
1 files changed, 16 insertions, 0 deletions
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()