(t *testing.T)
| 125 | } |
| 126 | |
| 127 | func 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 | |
| 163 | func TestVUpdate(t *testing.T) { |
| 164 | tempFilename := TempFilename(t) |
nothing calls this directly
no test coverage detected