Skip to content

[Issue]: P1: Setup Docker #49

@soramicha

Description

@soramicha

Branch Name

feature/49-test-database

Task

At the moment we are currently using our actual database to do our testings which isn't a good practice, so let's fix that. We will implement our test database using Docker. That way, we can have isolated testing.

We don't have to containerize the entire project. We just need our test database that can be cleaned, reset and reseeded with the empty data table design each time we run our tests. We should be able to start our docker container and create a .env.test with appropriate information such as DATABASE_URL that will be pointing locally to the docker container. We must create tables before we run our tests too (obviously). After testing, we should be able reset it by tearing down the container.

Steps:

Basic commands:

  • docker compose up -d <== set up docker container for test db
  • npm run seed:test <== to seed data
  • npm run test <== run our tests
  • docker compose down -v <== tear down container after testing's over

root directory/
docker-compose.yml
db-init/
seed.sql

Acceptance Criteria

  • Set up a Docker container
  • Create a .test.env for test db env info
  • Create a .sql to seed data
  • Successful creation of test db (creating test db, successful run of 'npm run test', tear down docker container, repeating the cycle...)

Checklist

  • I have checked for duplicate issues.
  • I have assigned the issue to the correct project board.
  • I have tagged the issue properly.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Labels

Type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions