func SetQueryWithArgsFunc(f func(query string, args []driver.Value) (result driver.Rows, err error)) {
	d.conn.queryFunc = f
}
Set your own function to be executed when db.Query() is called. As with StubQuery() you can use the RowsFromCSVString() method to easily generate the driver.Rows, or you can return your own.
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)
	})
}