1import { assert, it } from "@effect/vitest";
2import * as Effect from "effect/Effect";
3import * as Layer from "effect/Layer";
4import * as SqlClient from "effect/sql/SqlClient";
5
6import { runMigrations } from "../Migrations.ts";
7import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
8
9const layer = it.layer(Layer.mergeAll(NodeSqliteClient.layer({ filename: ":memory:" })));
10
11layer("040_ProjectionProjectFaviconPath", (it) => {
12 it.effect("adds the nullable favicon path to project projections", () =>
13 Effect.gen(function* () {
14 const sql = yield* SqlClient.SqlClient;
15
16 yield* runMigrations({ toMigrationInclusive: 39 });
17 yield* runMigrations({ toMigrationInclusive: 40 });
18
19 const columns = yield* sql<{ readonly name: string; readonly notnull: number }>`
20 PRAGMA table_info(projection_projects)
21 `;
22 const faviconPath = columns.find((column) => column.name === "favicon_path");
23
24 assert.equal(faviconPath?.name, "favicon_path");
25 assert.equal(faviconPath?.notnull, 0);
26 }),
27 );
28});