GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — prompts.chat/vitest.db.global-setup.ts at main · zgcoding/prompts.chat

Expand file tree

/

vitest.db.global-setup.ts

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
27 lines (24 loc) · 1.11 KB
/

vitest.db.global-setup.ts

Copy path

File metadata and controls

27 lines (24 loc) · 1.11 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import { execFileSync } from "node:child_process";
import { PrismaClient } from "@prisma/client";
/** Applies every migration to this run's own schema, and drops that schema when the run ends */
export default function setup() {
const base = process.env.TEST_DATABASE_URL;
const url = process.env.VITEST_DB_URL;
const schema = process.env.VITEST_DB_SCHEMA;
if (!base || !url || !schema) {
throw new Error("TEST_DATABASE_URL is required for database tests, e.g. postgresql://postgres:postgres@localhost:5432/prompts_chat_test");
}
const database = new URL(base).pathname.slice(1);
if (!/test/i.test(database)) {
throw new Error(`Refusing to use "${database}": the database tests only run on a database whose name contains "test"`);
}
execFileSync("npx", ["prisma", "migrate", "deploy"], { env: { ...process.env, DATABASE_URL: url, DIRECT_URL: url }, stdio: "pipe" });
return async () => {
const prisma = new PrismaClient({ datasourceUrl: base });
try {
await prisma.$executeRawUnsafe(`DROP SCHEMA IF EXISTS "${schema}" CASCADE`);
} finally {
await prisma.$disconnect();
}
};
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.