File tree Expand file tree Collapse file tree 4 files changed +10
-25
lines changed
Expand file tree Collapse file tree 4 files changed +10
-25
lines changed Original file line number Diff line number Diff line change 1+ DATABASE_PATH = " ./tests/prisma/base.db"
2+ DATABASE_URL = file:../tests/prisma/base.db
Original file line number Diff line number Diff line change 3030 - name : 📥 Download deps
3131 uses : bahmutov/npm-install@v1
3232
33- - name : 🏄 Copy test env vars
34- run : cp .env.example .env
35-
3633 - name : 🛠 Setup Database
3734 run : npx prisma migrate deploy && npx prisma generate --sql
3835
5754 - name : 🏗 Build
5855 run : npm run build
5956
60- - name : 🏄 Copy test env vars
61- run : cp .env.example .env
62-
6357 - name : 🛠 Setup Database
6458 run : npx prisma migrate deploy && npx prisma generate --sql
6559
8175 - name : 📥 Download deps
8276 uses : bahmutov/npm-install@v1
8377
84- - name : 🏄 Copy test env vars
85- run : cp .env.example .env
86-
8778 - name : 🛠 Setup Database
8879 run : npx prisma migrate deploy && npx prisma generate --sql
8980
9889 - name : ⬇️ Checkout repo
9990 uses : actions/checkout@v4
10091
101- - name : 🏄 Copy test env vars
102- run : cp .env.example .env
103-
10492 - name : ⎔ Setup node
10593 uses : actions/setup-node@v4
10694 with :
Original file line number Diff line number Diff line change 11import path from 'node:path'
22import fsExtra from 'fs-extra'
3+ import { ENV } from 'varlock/env'
34import { afterAll , beforeEach } from 'vitest'
4- import { BASE_DATABASE_PATH } from './global-setup.ts'
55
66const databaseFile = `./tests/prisma/data.${ process . env . VITEST_POOL_ID || 0 } .db`
77const databasePath = path . join ( process . cwd ( ) , databaseFile )
88process . env . DATABASE_URL = `file:${ databasePath } `
99
1010beforeEach ( async ( ) => {
11- await fsExtra . copyFile ( BASE_DATABASE_PATH , databasePath )
11+ await fsExtra . copyFile ( ENV . DATABASE_PATH , databasePath )
1212} )
1313
1414afterAll ( async ( ) => {
Original file line number Diff line number Diff line change 11import 'varlock/auto-load'
2- import path from 'node:path '
2+ import { fileURLToPath } from 'node:url '
33import { execaCommand } from 'execa'
44import fsExtra from 'fs-extra'
5+ import { ENV } from 'varlock/env'
56import '#app/utils/cache.server.ts'
67
7- export const BASE_DATABASE_PATH = path . join (
8- process . cwd ( ) ,
9- `./tests/prisma/base.db` ,
10- )
8+
119
1210export async function setup ( ) {
13- const databaseExists = await fsExtra . pathExists ( BASE_DATABASE_PATH )
11+ const dbPath = fileURLToPath ( ENV . DATABASE_URL ) ;
12+ const databaseExists = await fsExtra . pathExists ( dbPath )
1413
1514 if ( databaseExists ) {
16- const databaseLastModifiedAt = ( await fsExtra . stat ( BASE_DATABASE_PATH ) )
15+ const databaseLastModifiedAt = ( await fsExtra . stat ( dbPath ) )
1716 . mtime
1817 const prismaSchemaLastModifiedAt = (
1918 await fsExtra . stat ( './prisma/schema.prisma' )
@@ -28,10 +27,6 @@ export async function setup() {
2827 'npx prisma migrate reset --force --skip-seed --skip-generate' ,
2928 {
3029 stdio : 'inherit' ,
31- env : {
32- ...process . env ,
33- DATABASE_URL : `file:${ BASE_DATABASE_PATH } ` ,
34- } ,
3530 } ,
3631 )
3732}
You can’t perform that action at this time.
0 commit comments