MCPcopy
hub / github.com/go-sql-driver/mysql / TestValuerWithValidation

Function TestValuerWithValidation

driver_test.go:759–792  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

757}
758
759func TestValuerWithValidation(t *testing.T) {
760 runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
761 in := testValuerWithValidation{"a_value"}
762 var out string
763 var rows *sql.Rows
764
765 dbt.mustExec("CREATE TABLE " + tbl + " (value VARCHAR(255)) CHARACTER SET utf8")
766 dbt.mustExec("INSERT INTO "+tbl+" VALUES (?)", in)
767
768 rows = dbt.mustQuery("SELECT value FROM " + tbl)
769 defer rows.Close()
770
771 if rows.Next() {
772 rows.Scan(&out)
773 if in.value != out {
774 dbt.Errorf("Valuer: %v != %s", in, out)
775 }
776 } else {
777 dbt.Errorf("Valuer: no data")
778 }
779
780 if _, err := dbt.db.Exec("INSERT INTO "+tbl+" VALUES (?)", testValuerWithValidation{""}); err == nil {
781 dbt.Errorf("Failed to check valuer error")
782 }
783
784 if _, err := dbt.db.Exec("INSERT INTO "+tbl+" VALUES (?)", nil); err != nil {
785 dbt.Errorf("Failed to check nil")
786 }
787
788 if _, err := dbt.db.Exec("INSERT INTO "+tbl+" VALUES (?)", map[string]bool{}); err == nil {
789 dbt.Errorf("Failed to check not valuer")
790 }
791 })
792}
793
794type timeTests struct {
795 dbtype string

Callers

nothing calls this directly

Calls 7

runTestsParallelFunction · 0.85
mustExecMethod · 0.80
mustQueryMethod · 0.80
ScanMethod · 0.80
CloseMethod · 0.45
NextMethod · 0.45
ExecMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…