Skip to content

Commit

Permalink
add t.Run to migrations_test
Browse files Browse the repository at this point in the history
  • Loading branch information
robinjoseph08 committed Oct 17, 2024
1 parent a6e73b5 commit f7b5fc5
Showing 1 changed file with 32 additions and 25 deletions.
57 changes: 32 additions & 25 deletions migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,36 +40,43 @@ func TestRunWithOptions(t *testing.T) {
Database: os.Getenv("TEST_DATABASE_NAME"),
})
db.AddQueryHook(logQueryHook{})
dropMigrationTables(t, db)

err := RunWithOptions(db, tmp, []string{"cmd", "migrate"}, RunOptions{})
assert.Nil(t, err)
assertTable(t, db, "migrations", true)
assertTable(t, db, "migration_lock", true)
assertTable(t, db, "custom_migrations", false)
assertTable(t, db, "custom_migration_lock", false)
t.Run("default", func(tt *testing.T) {

Check failure on line 44 in migrations_test.go

View workflow job for this annotation

GitHub Actions / build

unused-parameter: parameter 'tt' seems to be unused, consider removing or renaming it as _ (revive)
dropMigrationTables(t, db)

err := RunWithOptions(db, tmp, []string{"cmd", "migrate"}, RunOptions{})
assert.Nil(t, err)
assertTable(t, db, "migrations", true)
assertTable(t, db, "migration_lock", true)
assertTable(t, db, "custom_migrations", false)
assertTable(t, db, "custom_migration_lock", false)
})

dropMigrationTables(t, db)
t.Run("custom tables - migrate", func(tt *testing.T) {

Check failure on line 55 in migrations_test.go

View workflow job for this annotation

GitHub Actions / build

unused-parameter: parameter 'tt' seems to be unused, consider removing or renaming it as _ (revive)
dropMigrationTables(t, db)

err = RunWithOptions(db, tmp, []string{"cmd", "migrate"}, RunOptions{
MigrationsTableName: "custom_migrations",
MigrationLockTableName: "custom_migration_lock",
err := RunWithOptions(db, tmp, []string{"cmd", "migrate"}, RunOptions{
MigrationsTableName: "custom_migrations",
MigrationLockTableName: "custom_migration_lock",
})
assert.Nil(t, err)
assertTable(t, db, "custom_migrations", true)
assertTable(t, db, "custom_migration_lock", true)
assertTable(t, db, "migrations", false)
assertTable(t, db, "migration_lock", false)
})
assert.Nil(t, err)
assertTable(t, db, "custom_migrations", true)
assertTable(t, db, "custom_migration_lock", true)
assertTable(t, db, "migrations", false)
assertTable(t, db, "migration_lock", false)

dropMigrationTables(t, db)
t.Run("custom tables - rollback", func(tt *testing.T) {

Check failure on line 69 in migrations_test.go

View workflow job for this annotation

GitHub Actions / build

unused-parameter: parameter 'tt' seems to be unused, consider removing or renaming it as _ (revive)
dropMigrationTables(t, db)

err = RunWithOptions(db, tmp, []string{"cmd", "rollback"}, RunOptions{
MigrationsTableName: "custom_migrations",
MigrationLockTableName: "custom_migration_lock",
err := RunWithOptions(db, tmp, []string{"cmd", "rollback"}, RunOptions{
MigrationsTableName: "custom_migrations",
MigrationLockTableName: "custom_migration_lock",
})
assert.Nil(t, err)
assertTable(t, db, "custom_migrations", true)
assertTable(t, db, "custom_migration_lock", true)
assertTable(t, db, "migrations", false)
assertTable(t, db, "migration_lock", false)
})
assert.Nil(t, err)
assertTable(t, db, "custom_migrations", true)
assertTable(t, db, "custom_migration_lock", true)
assertTable(t, db, "migrations", false)
assertTable(t, db, "migration_lock", false)
}

0 comments on commit f7b5fc5

Please sign in to comment.