Skip to content

Commit

Permalink
tests: fix number comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
mfridman committed Nov 2, 2024
1 parent 8f6abb6 commit 4a80e05
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions tests/gomigrations/error/gomigrations_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -32,15 +32,15 @@ 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)
require.Error(t, err)
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.
Expand All @@ -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)

}
6 changes: 3 additions & 3 deletions tests/gomigrations/success/gomigrations_success_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 4a80e05

Please sign in to comment.