Skip to content

Commit 4ca4261

Browse files
chore: wip
1 parent 75e54c4 commit 4ca4261

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

storage/framework/core/database/src/drivers/sqlite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function fetchSqliteFile(): string {
6464
}
6565

6666
export function fetchTestSqliteFile(): string {
67-
const dbPath = path.userDatabasePath('stacks-testing.sqlite')
67+
const dbPath = path.userDatabasePath('stacks_testing.sqlite')
6868

6969
return dbPath
7070
}

storage/framework/core/testing/src/database.ts

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,26 @@ export async function setupDatabase() {
1111

1212
await runDatabaseMigration()
1313
}
14-
15-
if (driver === 'sqlite') {
16-
await sql`CREATE DATABASE IF NOT EXISTS ${sql.raw(dbName)}`.execute(db)
17-
18-
await runDatabaseMigration()
19-
}
2014
}
2115

22-
// export async function refreshDatabase() {
23-
// if (driver === 'mysql') await truncateMysql()
16+
export async function refreshDatabase() {
17+
if (driver === 'mysql') await truncateMysql()
2418

25-
// if (driver === 'sqlite') await truncateSqlite()
26-
// }
27-
28-
// export async function truncateMysql() {
29-
// const tables = await fetchTables()
19+
if (driver === 'sqlite') await truncateSqlite()
20+
}
3021

31-
// for (const table of tables) {
32-
// await sql`TRUNCATE TABLE ${sql.raw(table)}`.execute(db)
33-
// }
34-
// }
22+
export async function truncateMysql() {
23+
const tables = await fetchTables()
3524

36-
// export async function truncateSqlite() {
37-
// const dbPath = await fetchTestSqliteFile()
25+
for (const table of tables) {
26+
await sql`TRUNCATE TABLE ${sql.raw(table)}`.execute(db)
27+
}
28+
}
3829

39-
// if (fs.existsSync(dbPath)) await Bun.$`rm ${dbPath}`
30+
export async function truncateSqlite() {
31+
const dbPath = await fetchTestSqliteFile()
4032

41-
// await runDatabaseMigration()
42-
// }
33+
if (fs.existsSync(dbPath)) await Bun.$`rm ${dbPath}`
4334

44-
await setupDatabase()
35+
await runDatabaseMigration()
36+
}

0 commit comments

Comments
 (0)