Skip to content

Commit

Permalink
test server
Browse files Browse the repository at this point in the history
  • Loading branch information
Hayley Ashby committed Apr 19, 2024
1 parent 85464dd commit 88d9530
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/CI and Deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,15 @@ jobs:
build:
name: Node.js CI
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: ${{ secrets.PG_USER }}
POSTGRES_PASSWORD: ${{ secrets.PG_PW }}
POSTGRES_DB: ${{ secrets.PG_DB }}
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
- run: npm ci
- run: npm install -g json-server
- run: json-server --watch db.json --routes routes.json --port 3000 &
- run: npm run build --if-present
- run: npm test
env:
Expand All @@ -36,7 +28,7 @@ jobs:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
KANKA_TOKEN: ${{ secrets.KANKA_TOKEN }}
DB_TOKEN: ${{ secrets.DB_TOKEN }}
DB_URL: postgres://postgres:postgres@localhost:5432/testDB
DB_URL: http://localhost:3000

deploy:
name: Fly Deploy
Expand Down
8 changes: 8 additions & 0 deletions src/mocks/db/db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"stats": [
{
"name": "EchoesLeft",
"value": 123
}
]
}
3 changes: 3 additions & 0 deletions src/mocks/db/routes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"/stats?name=eq.EchoesLeft": "/stats/0"
}
2 changes: 1 addition & 1 deletion src/services/dbClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios, { AxiosRequestConfig, RawAxiosRequestHeaders } from 'axios';
import { config } from '../config';

export const dbClient = axios.create({
baseURL: config.DB_URL,
baseURL: process.env.NODE_ENV === 'test' ? 'http://localhost:3000' : config.DB_URL,
});

export const dbConfig: AxiosRequestConfig = {
Expand Down

0 comments on commit 88d9530

Please sign in to comment.