-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration.test.ts
More file actions
32 lines (27 loc) · 896 Bytes
/
integration.test.ts
File metadata and controls
32 lines (27 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import * as fs from "node:fs/promises";
import { describe, expect, test, vitest } from "vitest";
import { TmpDb } from "./disk_store";
import { faker } from "@faker-js/faker";
const DB_FILE = "./tmp/tmpdb.db";
const cleanUp = async () => {
await fs.rm(DB_FILE, { force: true });
};
describe("writes and reads", () => {
const NUM: number = 1000;
const data: { key: string; value: string }[] = [];
for (let i = 0; i < NUM; i++) {
const key = faker.person.fullName();
const value = faker.airline.flightNumber();
data.push({ key: key, value: value });
}
test("writing a lot of random data gives expected outputs back", async () => {
await cleanUp();
const db = new TmpDb(DB_FILE);
await db.initialize();
for (const d of data) {
await db.set(d.key, d.value);
const val = await db.get(d.key);
expect(val).toEqual(d.value);
}
});
});