func Reset() {
	d.conn = newConn()
	d.openFunc = nil
}
Clears all stubbed queries, and replaced functions.
package testdb
import (
	"crypto/sha1"
	"database/sql"
	"database/sql/driver"
	"encoding/csv"
	"io"
	"regexp"
	"strings"
	"time"
)
var d *testDriver
func init() {
	d = newDriver()
	sql.Register("testdb", d)
}
type testDriver struct {
	openFunc          func(dsn string) (driver.Conn, error)
	conn              *conn
	enableTimeParsing bool
}
type query struct {
	rows   driver.Rows
	result *Result
	err    error
}
func newDriver() *testDriver {
	return &testDriver{
		conn: newConn(),
	}
}
func EnableTimeParsing(flag bool) {
	d.enableTimeParsing = flag
}
func (d *testDriver) Open(dsn string) (driver.Conn, error) {
	if d.openFunc != nil {
		conn, err := d.openFunc(dsn)
		return conn, err
	}
	if d.conn == nil {
		d.conn = newConn()
	}
	return d.conn, nil
}
var whitespaceRegexp = regexp.MustCompile("\\s")
func getQueryHash(query string) string {
	query = strings.ToLower(whitespaceRegexp.ReplaceAllString(query, ""))
	h := sha1.New()
	io.WriteString(h, query)
	return string(h.Sum(nil))
}
func SetQueryFunc(f func(query string) (result driver.Rows, err error)) {
	SetQueryWithArgsFunc(func(query string, args []driver.Value) (result driver.Rows, err error) {
		return f(query)
	})
}
func SetQueryWithArgsFunc(f func(query string, args []driver.Value) (result driver.Rows, err error)) {
	d.conn.queryFunc = f
}
func StubQuery(q string, rows driver.Rows) {
	d.conn.queries[getQueryHash(q)] = query{
		rows: rows,
	}
}
func StubQueryError(q string, err error) {
	d.conn.queries[getQueryHash(q)] = query{
		err: err,
	}
}
func SetOpenFunc(f func(dsn string) (driver.Conn, error)) {
	d.openFunc = f
}
func SetExecFunc(f func(query string) (driver.Result, error)) {
	SetExecWithArgsFunc(func(query string, args []driver.Value) (driver.Result, error) {
		return f(query)
	})
}
func SetExecWithArgsFunc(f func(query string, args []driver.Value) (driver.Result, error)) {
	d.conn.execFunc = f
}
func StubExec(q string, r *Result) {
	d.conn.queries[getQueryHash(q)] = query{
		result: r,
	}
}
func StubExecError(q string, err error) {
	StubQueryError(q, err)
}
func SetBeginFunc(f func() (driver.Tx, error)) {
	d.conn.beginFunc = f
}
func StubBegin(tx driver.Tx, err error) {
	SetBeginFunc(func() (driver.Tx, error) {
		return tx, err
	})
}
func SetCommitFunc(f func() error) {
	d.conn.commitFunc = f
}
func StubCommitError(err error) {
	SetCommitFunc(func() error {
		return err
	})
}
func SetRollbackFunc(f func() error) {
	d.conn.rollbackFunc = f
}
func StubRollbackError(err error) {
	SetRollbackFunc(func() error {
		return err
	})
}