mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
21 lines
504 B
TypeScript
21 lines
504 B
TypeScript
import { SimpleLRU } from './SimpleLRU.ts';
|
|
import { assertEquals, assertRejects } from '@std/assert';
|
|
|
|
Deno.test("SimpleLRU doesn't repeat failed calls", async () => {
|
|
let calls = 0;
|
|
|
|
using cache = new SimpleLRU(
|
|
// deno-lint-ignore require-await
|
|
async () => {
|
|
calls++;
|
|
throw new Error('gg');
|
|
},
|
|
{ max: 100 },
|
|
);
|
|
|
|
await assertRejects(() => cache.fetch('foo'));
|
|
assertEquals(calls, 1);
|
|
|
|
await assertRejects(() => cache.fetch('foo'));
|
|
assertEquals(calls, 1);
|
|
});
|