Skip to content

Commit

Permalink
Refactor: Pass db related env var to make test target
Browse files Browse the repository at this point in the history
Signed-off-by: Kaung Zin Hein <[email protected]>
  • Loading branch information
Zen-cronic committed Feb 21, 2025
1 parent df47070 commit 75a6965
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 13 deletions.
2 changes: 0 additions & 2 deletions .env.test

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ docker-run:
docker run -it --rm --name $(DOCKER_IMAGE_NAME)-01 $(DOCKER_IMAGE_NAME)

test:
NODE_ENV=test npx tsx --test ${TEST_FILES}
DB_DRIVER=sqlite DB_FILENAME=":memory:" npx tsx --test ${TEST_FILES}

lint:
npx tsc --noemit
Expand Down
8 changes: 1 addition & 7 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ if (process.env.PUBLIC_URI === undefined) {
// that we may be missing a .env file.
//
// This is the only required environment variable.
if(process.env.NODE_ENV === 'test'){
dotenv.config({ path: './.env.test' });
}
else{
dotenv.config({path: dirname(fileURLToPath(import.meta.url)) + '/../.env'});
}

dotenv.config({path: dirname(fileURLToPath(import.meta.url)) + '/../.env'});
} else {
console.warn('/env.js was loaded twice?');
}
3 changes: 0 additions & 3 deletions test/pagination/services.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { strict as assert } from 'node:assert';
import { after, before, describe, it } from 'node:test';

import * as dotenv from 'dotenv';
dotenv.config({ path: './.env.test'});

import { PrincipalService, recordToModel } from '../../src/principal/service.ts';
import db, { insertAndGetId } from '../../src/database.ts';

Expand Down

0 comments on commit 75a6965

Please sign in to comment.