Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pengux/sqlassert
Go package with assertion helpers for SQL databases
https://github.com/pengux/sqlassert
Last synced: 3 months ago
JSON representation
Go package with assertion helpers for SQL databases
- Host: GitHub
- URL: https://github.com/pengux/sqlassert
- Owner: pengux
- License: mit
- Created: 2021-08-02T07:19:14.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-20T09:00:59.000Z (over 2 years ago)
- Last Synced: 2024-06-19T20:51:01.590Z (7 months ago)
- Language: Go
- Size: 57.6 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![CI](https://github.com/pengux/sqlassert/actions/workflows/ci.yml/badge.svg)
[![Go Reference](https://pkg.go.dev/badge/github.com/pengux/sqlassert.svg)](https://pkg.go.dev/github.com/pengux/sqlassert)
[![Go Report Card](https://goreportcard.com/badge/github.com/pengux/sqlassert)](https://goreportcard.com/report/github.com/pengux/sqlassert)# sqlassert
Go package with assertion helpers for SQL databasesUse `sqlassert` in your integration tests or write assertions for schema changes and migraton scripts.
## Usage
```
go get github.com/pengux/sqlassert
```Example:
```
package migration_testimport (
"testing""github.com/pengux/sqlassert"
)func TestMigration(t *testing.T) {
...
// db is *sql.DB
pgassert := sqlassert.NewPostgresAsserter(db)table := "table_name"
column := "column_name"
index := "index_name"
constraint := "constraint_name"
id := "123"pgassert.TableExists(t, table)
pgassert.ColumnExists(t, table, column)
pgassert.ConstraintExists(t, table, column, constraint)
pgassert.RowExists(t, table, map[string]interface{}{
"id": id,
})
pgassert.IndexExists(t, table, index)
}
```## Supported databases
- [x] Postgresql
- [x] Mysql
- [ ] SQLite
- [ ] Microsoft SQL Server
- [ ] Oracle