mirror of https://github.com/pressly/goose.git
tests: fix number comparison
parent
8f6abb60f8
commit
4a80e05733
4
Makefile
4
Makefile
|
@ -41,11 +41,11 @@ tools:
|
|||
@go install github.com/mfridman/tparse@latest
|
||||
|
||||
test-packages:
|
||||
go test $(GO_TEST_FLAGS) $$(go list ./... | grep -v -e /tests -e /bin -e /cmd -e /examples) |\
|
||||
go test $(GO_TEST_FLAGS) $$(go list ./... | grep -v -e /bin -e /cmd -e /examples) |\
|
||||
tparse --follow -sort=elapsed
|
||||
|
||||
test-packages-short:
|
||||
go test -test.short $(GO_TEST_FLAGS) $$(go list ./... | grep -v -e /tests -e /bin -e /cmd -e /examples) |\
|
||||
go test -test.short $(GO_TEST_FLAGS) $$(go list ./... | grep -v -e /bin -e /cmd -e /examples) |\
|
||||
tparse --follow -sort=elapsed
|
||||
|
||||
coverage-short:
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestGoMigrationByOne(t *testing.T) {
|
|||
// Create goose table.
|
||||
current, err := goose.EnsureDBVersion(db)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 0, current)
|
||||
require.EqualValues(t, 0, current)
|
||||
// Collect migrations.
|
||||
dir := "testdata"
|
||||
migrations, err := goose.CollectMigrations(dir, 0, goose.MaxVersion)
|
||||
|
@ -32,7 +32,7 @@ func TestGoMigrationByOne(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
version, err := goose.GetDBVersion(db)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, version)
|
||||
require.EqualValues(t, 1, version)
|
||||
|
||||
// Registered Go migration run outside a goose tx using *sql.DB.
|
||||
err = migrations[1].Up(db)
|
||||
|
@ -40,7 +40,7 @@ func TestGoMigrationByOne(t *testing.T) {
|
|||
require.Contains(t, err.Error(), "failed to run go migration")
|
||||
version, err = goose.GetDBVersion(db)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, version)
|
||||
require.EqualValues(t, 1, version)
|
||||
|
||||
// This migration was inserting 100 rows, but fails at 50, and
|
||||
// because it's run outside a goose tx then we expect 50 rows.
|
||||
|
@ -63,11 +63,11 @@ func TestGoMigrationByOne(t *testing.T) {
|
|||
require.Contains(t, err.Error(), "failed to run go migration")
|
||||
version, err = goose.GetDBVersion(db)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 3, version) // This migration failed, so we're still at 3.
|
||||
require.EqualValues(t, 3, version) // This migration failed, so we're still at 3.
|
||||
// This migration was inserting 100 rows, but fails at 50. However, since it's
|
||||
// running within a tx we expect none of the inserts to persist.
|
||||
err = db.QueryRow("SELECT COUNT(*) FROM foo").Scan(&count)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 0, count)
|
||||
require.EqualValues(t, 0, count)
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ func TestGoMigrationByOne(t *testing.T) {
|
|||
}
|
||||
// Migrate all files up-by-one.
|
||||
for i := 1; i <= len(files); i++ {
|
||||
require.Equal(t, upByOne(t), i)
|
||||
require.EqualValues(t, upByOne(t), i)
|
||||
}
|
||||
version, err := goose.GetDBVersion(db)
|
||||
require.NoError(t, err)
|
||||
|
@ -67,11 +67,11 @@ func TestGoMigrationByOne(t *testing.T) {
|
|||
|
||||
// Migrate all files down-by-one.
|
||||
for i := len(files) - 1; i >= 0; i-- {
|
||||
require.Equal(t, downByOne(t), i)
|
||||
require.EqualValues(t, downByOne(t), i)
|
||||
}
|
||||
version, err = goose.GetDBVersion(db)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 0, version)
|
||||
require.EqualValues(t, 0, version)
|
||||
|
||||
tables, err = ListTables(db)
|
||||
require.NoError(t, err)
|
||||
|
|
Loading…
Reference in New Issue