This repository provides a framework for unit testing Postgres stored procedures using a local Docker container.
Unit testing stored procedures can be challenging due to the lack of native testing tools. This setup leverages a Postgres container to allow for efficient, isolated tests that run entirely on your own machine.
- Install dependencies:
pip install -r requirements.txt- Run a Postgres container:
docker run --name pg -p 5432:5432 -e POSTGRES_PASSWORD=password -e POSTGRES_DB=ea -d postgres:16.1-alpine- Run the tests
# The entire test suite
pytest
# Or the tests within a file
pytest test_database.py
# Or a single test
pytest test_database.py::test_sp_add_entry