-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnulldb_test.go
81 lines (59 loc) · 1.36 KB
/
nulldb_test.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package sqltracing_test
import (
"context"
"database/sql/driver"
"io"
)
type nullDriver struct {
con driver.Conn
}
func (d *nullDriver) Open(_ string) (driver.Conn, error) {
return d.con, nil
}
type nullStmt struct{}
func (s *nullStmt) Close() error {
return nil
}
func (s *nullStmt) NumInput() int {
return 0
}
func (s *nullStmt) Query(_ []driver.Value) (driver.Rows, error) {
return &nullRows{}, nil
}
func (s *nullStmt) Exec(_ []driver.Value) (driver.Result, error) {
return nil, nil
}
type nullRows struct{}
type nullTx struct{}
func (r *nullRows) Close() error {
return nil
}
func (r *nullRows) Columns() []string {
return []string{"1"}
}
func (r *nullRows) Next(_ []driver.Value) error {
return io.EOF
}
func (t *nullTx) Commit() error {
return nil
}
func (t *nullTx) Rollback() error {
return nil
}
type nullCon struct{}
func (c *nullCon) Prepare(_ string) (driver.Stmt, error) {
return &nullStmt{}, nil
}
func (c *nullCon) Close() error { return nil }
func (c *nullCon) Begin() (driver.Tx, error) {
return &nullTx{}, nil
}
func (c *nullCon) QueryContext(_ context.Context, _ string, _ []driver.NamedValue) (driver.Rows, error) {
return &nullRows{}, nil
}
func (c *nullCon) ExecContext(_ context.Context, _ string, _ []driver.NamedValue) (driver.Result, error) {
return nil, nil
}
func (c *nullCon) Ping(_ context.Context) error {
return nil
}