@@ -10,8 +10,6 @@ import (
10
10
"fmt"
11
11
"os"
12
12
"testing"
13
-
14
- "github.com/stretchr/testify/assert"
15
13
)
16
14
17
15
type testModule struct {
@@ -29,13 +27,27 @@ type testVTabCursor struct {
29
27
}
30
28
31
29
func (m testModule ) Create (c * SQLiteConn , args []string ) (VTab , error ) {
32
- assert .True (m .t , len (args ) == 6 , "six arguments expected" )
33
- assert .Equal (m .t , "test" , args [0 ], "module name" )
34
- assert .Equal (m .t , "main" , args [1 ], "db name" )
35
- assert .Equal (m .t , "vtab" , args [2 ], "table name" )
36
- assert .Equal (m .t , "'1'" , args [3 ], "first arg" )
37
- assert .Equal (m .t , "2" , args [4 ], "second arg" )
38
- assert .Equal (m .t , "three" , args [5 ], "third arg" )
30
+ if len (args ) != 6 {
31
+ m .t .Fatal ("six arguments expected" )
32
+ }
33
+ if args [0 ] != "test" {
34
+ m .t .Fatal ("module name" )
35
+ }
36
+ if args [1 ] != "main" {
37
+ m .t .Fatal ("db name" )
38
+ }
39
+ if args [2 ] != "vtab" {
40
+ m .t .Fatal ("table name" )
41
+ }
42
+ if args [3 ] != "'1'" {
43
+ m .t .Fatal ("first arg" )
44
+ }
45
+ if args [4 ] != "2" {
46
+ m .t .Fatal ("second arg" )
47
+ }
48
+ if args [5 ] != "three" {
49
+ m .t .Fatal ("third argsecond arg" )
50
+ }
39
51
err := c .DeclareVTab ("CREATE TABLE x(test TEXT)" )
40
52
if err != nil {
41
53
return nil , err
@@ -116,17 +128,27 @@ func TestCreateModule(t *testing.T) {
116
128
},
117
129
})
118
130
db , err := sql .Open ("sqlite3_TestCreateModule" , tempFilename )
119
- assert .Nil (t , err , "could not open db" )
131
+ if err != nil {
132
+ t .Fatalf ("could not open db: %v" , err )
133
+ }
120
134
_ , err = db .Exec ("CREATE VIRTUAL TABLE vtab USING test('1', 2, three)" )
121
- assert .Nil (t , err , "could not create vtable" )
135
+ if err != nil {
136
+ t .Fatal ("could not create vtable: %v" , err )
137
+ }
122
138
123
139
var i , value int
124
140
rows , err := db .Query ("SELECT rowid, * FROM vtab WHERE test = '3'" )
125
- assert .Nil (t , err , "couldn't select from virtual table" )
141
+ if err != nil {
142
+ t .Fatalf ("couldn't select from virtual table: %v" , err )
143
+ }
126
144
for rows .Next () {
127
145
rows .Scan (& i , & value )
128
- assert .Equal (t , intarray [i ], value )
146
+ if intarray [i ] != value {
147
+ t .Fatalf ("want %v but %v" , intarray [i ], value )
148
+ }
129
149
}
130
150
_ , err = db .Exec ("DROP TABLE vtab" )
131
- assert .Nil (t , err , "couldn't drop virtual table" )
151
+ if err != nil {
152
+ t .Fatalf ("couldn't drop virtual table: %v" , err )
153
+ }
132
154
}
0 commit comments