feat: release 2.7.0-rc2
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import { afterEach, describe, expect, test } from "bun:test";
|
||||
import { mkdtemp, readFile, rm, stat } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
mkdir,
|
||||
mkdtemp,
|
||||
readFile,
|
||||
rm,
|
||||
stat,
|
||||
writeFile,
|
||||
} from "node:fs/promises";
|
||||
import { dirname, join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import {
|
||||
getSessionPath,
|
||||
@@ -69,6 +76,35 @@ describe("API sessions", () => {
|
||||
expect(await readSession()).toBeUndefined();
|
||||
});
|
||||
|
||||
test("removes malformed runtime sessions without caching them", async () => {
|
||||
await setupDirectories();
|
||||
const path = getSessionPath(false);
|
||||
await mkdir(dirname(path), { recursive: true });
|
||||
await writeFile(
|
||||
path,
|
||||
JSON.stringify({ ...session, expiresAt: "not-a-date" }),
|
||||
);
|
||||
|
||||
expect(await readSession()).toBeUndefined();
|
||||
await expect(stat(path)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
expect(await readSession()).toBeUndefined();
|
||||
await writeSession(session, false);
|
||||
expect(await readSession()).toEqual(session);
|
||||
});
|
||||
|
||||
test("removes malformed persistent sessions", async () => {
|
||||
await setupDirectories();
|
||||
const path = getSessionPath(true);
|
||||
await mkdir(dirname(path), { recursive: true });
|
||||
await writeFile(
|
||||
path,
|
||||
JSON.stringify({ ...session, expiresAt: "not-a-date" }),
|
||||
);
|
||||
|
||||
expect(await readSession()).toBeUndefined();
|
||||
await expect(stat(path)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
});
|
||||
|
||||
test("invalidates a memoized missing session after writing", async () => {
|
||||
await setupDirectories();
|
||||
expect(await readSession()).toBeUndefined();
|
||||
|
||||
Reference in New Issue
Block a user