Skip to content

Commit

Permalink
introduce runTestsParallel to TestValuerWithValidation
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo82148 committed Oct 7, 2023
1 parent bbf766f commit ccb55f3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,15 +727,15 @@ func (tv testValuerWithValidation) Value() (driver.Value, error) {
}

func TestValuerWithValidation(t *testing.T) {
runTests(t, dsn, func(dbt *DBTest) {
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
in := testValuerWithValidation{"a_value"}
var out string
var rows *sql.Rows

dbt.mustExec("CREATE TABLE testValuer (value VARCHAR(255)) CHARACTER SET utf8")
dbt.mustExec("INSERT INTO testValuer VALUES (?)", in)
dbt.mustExec("CREATE TABLE " + tbl + " (value VARCHAR(255)) CHARACTER SET utf8")
dbt.mustExec("INSERT INTO "+tbl+" VALUES (?)", in)

rows = dbt.mustQuery("SELECT value FROM testValuer")
rows = dbt.mustQuery("SELECT value FROM " + tbl)
defer rows.Close()

if rows.Next() {
Expand All @@ -747,19 +747,19 @@ func TestValuerWithValidation(t *testing.T) {
dbt.Errorf("Valuer: no data")
}

if _, err := dbt.db.Exec("INSERT INTO testValuer VALUES (?)", testValuerWithValidation{""}); err == nil {
if _, err := dbt.db.Exec("INSERT INTO "+tbl+" VALUES (?)", testValuerWithValidation{""}); err == nil {
dbt.Errorf("Failed to check valuer error")
}

if _, err := dbt.db.Exec("INSERT INTO testValuer VALUES (?)", nil); err != nil {
if _, err := dbt.db.Exec("INSERT INTO "+tbl+" VALUES (?)", nil); err != nil {
dbt.Errorf("Failed to check nil")
}

if _, err := dbt.db.Exec("INSERT INTO testValuer VALUES (?)", map[string]bool{}); err == nil {
if _, err := dbt.db.Exec("INSERT INTO "+tbl+" VALUES (?)", map[string]bool{}); err == nil {
dbt.Errorf("Failed to check not valuer")
}

dbt.mustExec("DROP TABLE IF EXISTS testValuer")
dbt.mustExec("DROP TABLE IF EXISTS " + tbl)
})
}

Expand Down

0 comments on commit ccb55f3

Please sign in to comment.