Skip to content

Latest commit

 

History

History
56 lines (38 loc) · 2.74 KB

README.md

File metadata and controls

56 lines (38 loc) · 2.74 KB

SQL Testing Utilities

A Go library containing utilities that help when writing tests that use real SQL database servers.

Documentation Latest Version Build Status Code Coverage

This library is only intended for use as a test dependencies for projects within the Dogmatiq organization.

The primary feature is the NewDatabase() function which creates a temporary database that can be discarded at the end of each test.

Database Products

The database products in the table below are currently supported. Some products are supported via multiple different Go SQL drivers.

Product Supported Drivers Notes
MySQL mysql
MariaDB mysql
PostgreSQL pgx (preferred), postgres
SQLite sqlite3 Embedded database, requires CGO

Docker Stack

The docker-stack.yml file in this repository starts services for each of the supported database products. These services are typically required to run the tests for any project that depends on dogmatiq/sqltest.

The stack can be deployed using the following command:

curl https://raw.githubusercontent.com/dogmatiq/sqltest/main/docker-stack.yml | docker stack deploy dogmatiq-sqltest --compose-file -

GitHub Actions Configuration

Projects that depend on dogmatiq/sqltest should use the go+sql workflow. This workflow starts services for each of the supported database products, and runs the tests both with and without CGO enabled.

The workflow is chosen by changing the repository definition in the Terraform configuration. To see an example, check the definition of dogmatiq/sqltest itself, which uses this workflow.