-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlz_test.go
More file actions
50 lines (43 loc) · 1.18 KB
/
sqlz_test.go
File metadata and controls
50 lines (43 loc) · 1.18 KB
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
package sqlz
import (
"encoding/json"
"testing"
"time"
// "sqlz/sqlparser"
)
func TestSQLZ(t *testing.T) {
tcases := []struct {
desc string
query string
expectType SQL_Type
}{
{"create table sql.", "create table t1(id int, val int)", CREATE},
{"alter table sql.", "alter table t1 t2", ALTER},
{"drop table sql.", "drop table t1 t2", ALTER},
{"select sql.", "select * from t1 where id = 2", SELECT},
{"select sql.", "select * from t1,t2 where id = 2", SELECT},
{"insert sql.", "inSERT INTO t1(id, val) values(123,456),(678,90)", INSERT},
{"delete sql.", "delete from t1 where id=3", DELETE},
{"delete sql.", "delete from T1 where id=1", DELETE},
{"delete sql.", "delete from `t222` where id=1", DELETE},
{"update sql.", "update t1 set val=333 where id=1", UPDATE},
{"drop table sql.", "drop table t1", DROP},
{"show tables", "show tables", SHOW},
{"error sql", "error sql", ERROR_SQL},
{"unknow sql", "set @@a=1", UNKNOW},
}
StartZ()
for _, tcase := range tcases {
Z(tcase.query)
}
time.Sleep(time.Second)
st := Status()
byt, err := json.Marshal(st)
if err != nil {
t.Error(err.Error())
} else {
println(string(byt))
}
StopZ()
StopZ()
}