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

View file

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

View file

@ -12,7 +12,7 @@
"start:rc": "docker-compose -f docker-compose.rc.yml --env-file .env up --build", "start:rc": "docker-compose -f docker-compose.rc.yml --env-file .env up --build",
"start:prod": "docker-compose --env-file .env up --build", "start:prod": "docker-compose --env-file .env up --build",
"build:common": "cd packages/common && npm run 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" "version": "echo $npm_package_version"
}, },
"devDependencies": { "devDependencies": {

View file

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

View file

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