-
Notifications
You must be signed in to change notification settings - Fork 2
/
stmt_test.go
77 lines (58 loc) · 1.41 KB
/
stmt_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
package rwdb
import (
"testing"
"time"
)
func TestStmtClose(t *testing.T) {
stmtc, _ := db.Prepare("INSERT")
err := stmtc.Close()
if err != nil {
t.Errorf("unexpected error %v", err)
}
}
func TestStmtExec(t *testing.T) {
stmt := &stmt{}
_, err := stmt.Exec("INSERT")
if err.Error() != "zero statement executable" {
t.Errorf("unexpected error %v", err)
}
stmtc, _ := db.Prepare("INSERT")
_, err = stmtc.Exec()
if err != nil {
t.Errorf("unexpected error %v", err)
}
}
func TestStmtQuery(t *testing.T) {
stmt := &stmt{}
_, err := stmt.Query("SELECT")
if err.Error() != "zero statement executable" {
t.Errorf("unexpected error %v", err)
}
stmtc, _ := db.Prepare("SELECT")
_, err = stmtc.Query()
if err != nil {
t.Errorf("unexpected error %v", err)
}
dbt, _ := Open("fakedb", "foo", "fred")
time.Sleep(10 * time.Millisecond)
stmtc, _ = dbt.Prepare("SELECT")
time.Sleep(10 * time.Millisecond)
_, err = stmtc.Query()
if err != nil {
t.Errorf("unexpected error %v", err)
}
}
func TestStmtQueryRow(t *testing.T) {
stmt := &stmt{}
stmt.QueryRow("SELECT")
dbt, _ := Open("fakedb", "foo", "fred")
time.Sleep(10 * time.Millisecond)
stmtc, _ := dbt.Prepare("SELECT")
time.Sleep(10 * time.Millisecond)
stmtc.QueryRow("SELECT")
dbt, _ = Open("fakedb", "foo")
time.Sleep(10 * time.Millisecond)
stmtc, _ = dbt.Prepare("SELECT")
time.Sleep(10 * time.Millisecond)
stmtc.QueryRow("SELECT")
}