Something went wrong. Try again.
opencode v2 mirror
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768import { describe, expect, test } from "bun:test"import { canDisposeDirectory, pickDirectoriesToEvict } from "./global-sync/eviction"
describe("pickDirectoriesToEvict", () => { test("keeps pinned stores and evicts idle stores", () => { const now = 5_000 const picks = pickDirectoriesToEvict({ stores: ["a", "b", "c", "d"], state: new Map([ ["a", { lastAccessAt: 1_000 }], ["b", { lastAccessAt: 4_900 }], ["c", { lastAccessAt: 4_800 }], ["d", { lastAccessAt: 3_000 }], ]), pins: new Set(["a"]), max: 2, ttl: 1_500, now, })
expect(picks).toEqual(["d", "c"]) })})
describe("canDisposeDirectory", () => { test("rejects pinned or inflight directories", () => { expect( canDisposeDirectory({ directory: "dir", hasStore: true, pinned: true, booting: false, loadingSessions: false, }), ).toBe(false) expect( canDisposeDirectory({ directory: "dir", hasStore: true, pinned: false, booting: true, loadingSessions: false, }), ).toBe(false) expect( canDisposeDirectory({ directory: "dir", hasStore: true, pinned: false, booting: false, loadingSessions: true, }), ).toBe(false) })
test("accepts idle unpinned directory store", () => { expect( canDisposeDirectory({ directory: "dir", hasStore: true, pinned: false, booting: false, loadingSessions: false, }), ).toBe(true) })})