import { PostgreSqlContainer } from "@testcontainers/postgresql";
import { drizzle, PostgresJsDatabase } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import { beforeAll, afterAll, describe, it, expect } from "vitest";
import { Project } from "../project";
let db: PostgresJsDatabase<typeof schema> & { $client: postgres.Sql<{}> };
beforeAll(async () => {
const container = await new PostgreSqlContainer().start();
const connectionString = `postgres://postgres:${process.env.POSTGRES_PASSWORD}@${container.getHost()}:${container.getFirstMappedPort()}/test-db`;
const client = postgres(connectionString);
db = drizzle(client, { logger: false, schema });
});
afterAll(async () => {
await container.stop();
});
describe("listProjects", () => {
it("should return a list of projects", async () => {
const result = await Project.listProjects();
expect(result).toBeInstanceOf(Array);
expect(result.length).toBeGreaterThan(0);
});
});
import { PostgreSqlContainer } from "@testcontainers/postgresql";
import { drizzle, PostgresJsDatabase } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import { beforeAll, afterAll, describe, it, expect } from "vitest";
import { Project } from "../project";
let db: PostgresJsDatabase<typeof schema> & { $client: postgres.Sql<{}> };
beforeAll(async () => {
const container = await new PostgreSqlContainer().start();
const connectionString = `postgres://postgres:${process.env.POSTGRES_PASSWORD}@${container.getHost()}:${container.getFirstMappedPort()}/test-db`;
const client = postgres(connectionString);
db = drizzle(client, { logger: false, schema });
});
afterAll(async () => {
await container.stop();
});
describe("listProjects", () => {
it("should return a list of projects", async () => {
const result = await Project.listProjects();
expect(result).toBeInstanceOf(Array);
expect(result.length).toBeGreaterThan(0);
});
});