MCPcopy Create free account
hub / github.com/mattn/go-sqlite3 / TestCreateModule

Function TestCreateModule

sqlite3_opt_vtable_test.go:127–161  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

125}
126
127func TestCreateModule(t *testing.T) {
128 tempFilename := TempFilename(t)
129 defer os.Remove(tempFilename)
130 intarray := []int{1, 2, 3}
131 sql.Register("sqlite3_TestCreateModule", &SQLiteDriver{
132 ConnectHook: func(conn *SQLiteConn) error {
133 return conn.CreateModule("test", testModule{t, intarray})
134 },
135 })
136 db, err := sql.Open("sqlite3_TestCreateModule", tempFilename)
137 if err != nil {
138 t.Fatalf("could not open db: %v", err)
139 }
140 _, err = db.Exec("CREATE VIRTUAL TABLE vtab USING test('1', 2, three)")
141 if err != nil {
142 t.Fatalf("could not create vtable: %v", err)
143 }
144
145 var i, value int
146 rows, err := db.Query("SELECT rowid, * FROM vtab WHERE test = '3'")
147 if err != nil {
148 t.Fatalf("couldn't select from virtual table: %v", err)
149 }
150 for rows.Next() {
151 rows.Scan(&i, &value)
152 if intarray[i] != value {
153 t.Fatalf("want %v but %v", intarray[i], value)
154 }
155 }
156
157 _, err = db.Exec("DROP TABLE vtab")
158 if err != nil {
159 t.Fatalf("couldn't drop virtual table: %v", err)
160 }
161}
162
163func TestVUpdate(t *testing.T) {
164 tempFilename := TempFilename(t)

Callers

nothing calls this directly

Calls 7

TempFilenameFunction · 0.85
CreateModuleMethod · 0.80
OpenMethod · 0.65
NextMethod · 0.65
ExecMethod · 0.45
QueryMethod · 0.45
ScanMethod · 0.45

Tested by

no test coverage detected