mirror of
https://github.com/golang/go.git
synced 2026-06-27 03:11:23 +00:00
database/sql: run tests with different driver variants
Database drivers can support a variety of optional features. For example, a driver.Conn can optionally implement the Queryer and/or QueryerContext interfaces. We currently run most database/sql tests with a general-purpose test driver which implements most optional interfaces. Add support for running tests with a variety of different drivers. To start with, use two variations: A "basic" driver which only implements the minimal mandatory interfaces, and a "default" driver which implements most optional interfaces. For #67546 Change-Id: I60bd02260810b6468e6b02a1ac7544406a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/766700 Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
9be7615aa2
commit
c6eaf03788
2 changed files with 409 additions and 324 deletions
|
|
@ -62,8 +62,21 @@ type fakeConnector struct {
|
|||
|
||||
func (c *fakeConnector) Connect(context.Context) (driver.Conn, error) {
|
||||
conn, err := fdriver.Open(c.name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
conn.(*fakeConn).waiter = c.waiter
|
||||
return conn, err
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
func getFakeConn(c driver.Conn) *fakeConn {
|
||||
return c.(interface {
|
||||
getFakeConn() *fakeConn
|
||||
}).getFakeConn()
|
||||
}
|
||||
|
||||
func (c *fakeConn) getFakeConn() *fakeConn {
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *fakeConnector) Driver() driver.Driver {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue