Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHE-197] Add PG to BE Test Setup #155

Merged
merged 6 commits into from
Aug 8, 2024

Conversation

seantokuzo
Copy link
Contributor

@seantokuzo seantokuzo commented Jun 24, 2024

Description

  • adds postgres service to the testing environments (test all / solo)
  • sets environment variable values for testing environment
  • creates a postgres test db initialization script (same as dev init script minus seeding)
  • adds procedural script to test setup file to delete all rows from all tables before each test
  • sets node-postgres pool's host dependent on NODE_ENV
  • cleans up unused dotenv configuration in sql-db.ts
  • removes unused environment variable declaration from test setup

Jira Task

JIRA TICKET

Testing Instructions

  • run npm run docker-remove-all
  • in the server/controllers/ directory, create a file named applications.test.ts and paste in the following code:
import request from 'supertest';
import app from '../app';

it('confirms pg test setup', async () => {
  const response = await request(app)
    .get('/api/applications/statuses')
    .set('Cookie', await login())
    .send({});

  expect(response.body[0].name).toEqual('Applied');
});
  • run npm run docker-test:solo application
  • confirm test is successful

Passing test confirms postgres test service is running, has been initialized with proper tables and base data, and that our pool can connect to it and run queries in our unit tests

Checklist

All Team Members

  • I added a descriptive title to this PR.
  • I filled out the Description, Jira Task, and Testing Instructions sections above.
  • I added or updated [Jest unit tests]for any changes to components, server-side controllers, etc.
  • I ran npm run docker-test in my local environment to check that this PR passes all unit tests.
  • I did a quick check to make sure my code changes follow the recomended style guide.

@brok3turtl3 brok3turtl3 merged commit a59881d into dev Aug 8, 2024
1 check passed
@brok3turtl3 brok3turtl3 deleted the CHE-197/subtask/Add-PG-to-BE-Test-Setup branch August 8, 2024 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants