Commit 9dc1cce3 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick Committed by Ian Lance Taylor

database/sql: make TestDrivers not crash on second run

Using -test.cpu=1,1 made it crash before.

Fixes #9024

LGTM=iant
R=adg, iant
CC=golang-codereviews
https://golang.org/cl/169860043
parent 2074046d
......@@ -141,6 +141,8 @@ type Dummy struct {
}
func TestDrivers(t *testing.T) {
unregisterAllDrivers()
Register("test", fdriver)
Register("invalid", Dummy{})
all := Drivers()
if len(all) < 2 || !sort.StringsAreSorted(all) || !contains(all, "test") || !contains(all, "invalid") {
......
......@@ -37,6 +37,11 @@ func Register(name string, driver driver.Driver) {
drivers[name] = driver
}
func unregisterAllDrivers() {
// For tests.
drivers = make(map[string]driver.Driver)
}
// Drivers returns a sorted list of the names of the registered drivers.
func Drivers() []string {
var list []string
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment