Skip to content

Commit

Permalink
turn integration tests back on (#230)
Browse files Browse the repository at this point in the history
Co-authored-by: Bob Zhao <[email protected]>
  • Loading branch information
robertandremitchell and fzhao99 authored Dec 21, 2024
1 parent 699a0e4 commit 2970a0a
Show file tree
Hide file tree
Showing 12 changed files with 9,459 additions and 4,652 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,24 @@ jobs:
run: npm install
- name: Run tests
working-directory: ./query-connector
run: npm test
run: npm run test:unit

integration-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{env.NODE_VERSION}}
- name: Install dependencies
working-directory: ./query-connector
run: npm install

- name: Run tests
working-directory: ./query-connector
run: npm run test:integration

end-to-end-tests:
timeout-minutes: 15
Expand Down
30 changes: 30 additions & 0 deletions query-connector/docker-compose-integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
services:
# PostgreSQL DB for custom query and value set storage
db:
image: "postgres:alpine"
ports:
- "5432:5432"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=pw
- POSTGRES_DB=tefca_db

volumes:
- ./vs_dump.sql:/docker-entrypoint-initdb.d/vs_dump.sql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 2s
timeout: 5s
retries: 20

# Flyway migrations and DB version control
flyway:
image: flyway/flyway:10.16-alpine
command: -configFiles=/flyway/conf/flyway.conf -schemas=public -connectRetries=60 migrate
platform: linux/amd64
volumes:
- ./flyway/sql:/flyway/sql
- ./flyway/conf/flyway.conf:/flyway/conf/flyway.conf
depends_on:
db:
condition: service_started
18 changes: 18 additions & 0 deletions query-connector/integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -e # Exit immediately if a command exits with a non-zero status

docker compose -f docker-compose-integration.yaml up -d

# wait for flyway to finish running before...
docker compose -f docker-compose-integration.yaml logs -f flyway | grep -q "Successfully applied"

# running our integration tests
DATABASE_URL=postgresql://postgres:pw@localhost:5432/tefca_db TEST_TYPE=integration jest --testPathPattern=tests/integration
JEST_EXIT_CODE=$?

# Teardown containers
docker compose -f docker-compose-integration.yaml down

# Exit with the Jest exit code
exit $JEST_EXIT_CODE
13 changes: 13 additions & 0 deletions query-connector/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import { getDbClient } from "@/app/backend/dbClient";
import "@testing-library/jest-dom";
import { toHaveNoViolations } from "jest-axe";
import * as matchers from "jest-extended";
import { Pool } from "pg";

expect.extend(toHaveNoViolations);
expect.extend(matchers);

if (process.env.TEST_TYPE === "integration") {
let dbClient: Pool | null = null;
beforeAll(() => {
dbClient = getDbClient();
});

afterAll(async () => {
await dbClient?.end();
});
}
Loading

0 comments on commit 2970a0a

Please sign in to comment.