test: change test-db port to 5433 to be able to run it besides the main app

This commit is contained in:
Nicolas Meienberger 2022-07-28 19:48:25 +02:00
parent 3da4c353cd
commit 05c8dff8e2
5 changed files with 20 additions and 13 deletions

View file

@ -16,7 +16,7 @@ jobs:
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
- 5433:5432
# set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
@ -32,7 +32,7 @@ jobs:
with:
node-version: 16
- uses: pnpm/action-setup@v2.0.1
- uses: pnpm/action-setup@v2.2.2
name: Install pnpm
id: pnpm-install
with:

View file

@ -7,6 +7,7 @@ on:
jobs:
release:
if: github.repository == 'meienberger/runtipi'
runs-on: ubuntu-latest
steps:
- name: Checkout

View file

@ -12,7 +12,7 @@
"start:rc": "docker-compose -f docker-compose.rc.yml --env-file .env up --build",
"start:prod": "docker-compose --env-file .env up --build",
"build:common": "cd packages/common && npm run build",
"start:pg": "docker run --name test-db -p 5432:5432 -d --rm -e POSTGRES_PASSWORD=postgres postgres",
"start:pg": "docker run --name test-db -p 5433:5432 -d --rm -e POSTGRES_PASSWORD=postgres postgres",
"version": "echo $npm_package_version"
},
"devDependencies": {

View file

@ -3,7 +3,7 @@ import { DataSource } from 'typeorm';
export const connectionSource = new DataSource({
type: 'postgres',
host: 'localhost',
port: 5432,
port: 5433,
username: 'postgres',
password: 'postgres',
database: 'postgres',

View file

@ -4,12 +4,18 @@ import User from '../modules/auth/user.entity';
import pg from 'pg';
import Update from '../modules/system/update.entity';
const HOST = 'localhost';
const USER = 'postgres';
const DATABASE = 'postgres';
const PASSWORD = 'postgres';
const PORT = 5433;
const pgClient = new pg.Client({
user: 'postgres',
host: 'localhost',
database: 'postgres',
password: 'postgres',
port: 5432,
user: USER,
host: HOST,
database: DATABASE,
password: PASSWORD,
port: PORT,
});
export const setupConnection = async (testsuite: string): Promise<DataSource> => {
@ -21,10 +27,10 @@ export const setupConnection = async (testsuite: string): Promise<DataSource> =>
const AppDataSource = new DataSource({
name: 'default',
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'postgres',
password: 'postgres',
host: HOST,
port: PORT,
username: USER,
password: PASSWORD,
database: testsuite,
dropSchema: true,
logging: false,