mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-14 11:04:18 +01:00
feat: only run tests with Postgres if ALLOW_TO_USE_DATABASE_URL is set to true
This commit is contained in:
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') {
|
||||
|
||||
Reference in New Issue
Block a user