forked from logoove/sqlite
/
driver.go
53 lines (45 loc) · 971 Bytes
/
driver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2021 The Sqlite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package driver
import (
"database/sql"
"fmt"
)
// System Under Test.
type SUT interface {
CreateTables() error
InsertCustomer() string
InsertLineItem() string
InsertNation() string
InsertOrders() string
InsertPart() string
InsertPartSupp() string
InsertRegion() string
InsertSupplier() string
Name() string
OpenDB() (*sql.DB, error)
OpenMem() (SUT, *sql.DB, error)
Q1() string
Q2() string
QProperty() string
SetWD(path string) error
}
var registered = map[string]SUT{}
func Open(name string) SUT {
return registered[name]
}
func Register(sut SUT) {
nm := sut.Name()
if _, ok := registered[nm]; ok {
panic(fmt.Errorf("already registered: %s", nm))
}
registered[nm] = sut
}
func List() []string {
r := []string{}
for k := range registered {
r = append(r, k)
}
return r
}