Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pascaldekloe/sqltest
integration test library
https://github.com/pascaldekloe/sqltest
Last synced: about 1 month ago
JSON representation
integration test library
- Host: GitHub
- URL: https://github.com/pascaldekloe/sqltest
- Owner: pascaldekloe
- License: cc0-1.0
- Created: 2020-08-20T19:03:01.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-20T16:22:27.000Z (over 2 years ago)
- Last Synced: 2024-05-09T20:21:34.042Z (6 months ago)
- Language: Go
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SQL Test
… convenience library for the Go programming language. Tests can run isolated in
a dedicated transaction. An automated rollback after each test keeps the data
consistent and/or clean.[![API](https://pkg.go.dev/badge/github.com/pascaldekloe/sqltest.svg)](https://pkg.go.dev/github.com/pascaldekloe/sqltest)
```go
func init() {
// database configuration
sqltest.Setup("pgx", "host=localhost user=test database=postgres")
// optional connect string override with an environment variable
sqltest.EnvSetup("", "TEST_CONNECT_STRING")
}func TestWithSQLInteraction(t *testing.T) {
db := sqltest.NewTx(t)
// install package variables
DBExec = db.ExecContext
DBQuery = db.QueryContext// test …
// automatic rollback
}
```This is free and unencumbered software released into the
[public domain](https://creativecommons.org/publicdomain/zero/1.0).