Skip to content

Go package with assertion helpers for SQL databases

License

Notifications You must be signed in to change notification settings

pengux/sqlassert

Repository files navigation

CI Go Reference Go Report Card

sqlassert

Go package with assertion helpers for SQL databases

Use sqlassert in your integration tests or write assertions for schema changes and migraton scripts.

Usage

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)
}

Supported databases

  • Postgresql
  • Mysql
  • SQLite
  • Microsoft SQL Server
  • Oracle

About

Go package with assertion helpers for SQL databases

Resources

License

Stars

Watchers

Forks

Packages

No packages published