Go package with assertion helpers for SQL databases
Use sqlassert
in your integration tests or write assertions for schema changes and migraton scripts.
go get github.com/pengux/sqlassert
Example:
package migration_test
import (
"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)
}
- Postgresql
- Mysql
- SQLite
- Microsoft SQL Server
- Oracle