mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
feat: only run tests with Postgres if ALLOW_TO_USE_DATABASE_URL is set to true
This commit is contained in:
parent
7e965f4ade
commit
fed0c70f69
1 changed files with 10 additions and 1 deletions
11
src/test.ts
11
src/test.ts
|
|
@ -79,7 +79,7 @@ export async function getTestDB() {
|
|||
export const createTestDB = async (databaseUrl?: string) => {
|
||||
databaseUrl ??= Deno.env.get('DATABASE_URL') ?? 'sqlite://:memory:';
|
||||
|
||||
const dialect: 'sqlite' | 'postgres' = (() => {
|
||||
let dialect: 'sqlite' | 'postgres' = (() => {
|
||||
const protocol = databaseUrl.split(':')[0];
|
||||
switch (protocol) {
|
||||
case 'sqlite':
|
||||
|
|
@ -93,6 +93,15 @@ export const createTestDB = async (databaseUrl?: string) => {
|
|||
}
|
||||
})();
|
||||
|
||||
const allowToUseDATABASE_URL = Deno.env.get('ALLOW_TO_USE_DATABASE_URL')?.toLowerCase() ?? '';
|
||||
if (allowToUseDATABASE_URL !== 'true' && dialect === 'postgres') {
|
||||
console.warn(
|
||||
'%cRunning tests with sqlite, if you meant to use Postgres, run again with ALLOW_TO_USE_DATABASE_URL environment variable set to true',
|
||||
'color: yellow;',
|
||||
);
|
||||
dialect = 'sqlite';
|
||||
}
|
||||
|
||||
let kysely: Kysely<DittoTables>;
|
||||
|
||||
if (dialect === 'sqlite') {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue