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

Function TestCreateModuleEponymousOnly

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

Source from the content-addressed store, hash-verified

587}
588
589func TestCreateModuleEponymousOnly(t *testing.T) {
590 tempFilename := TempFilename(t)
591 defer os.Remove(tempFilename)
592 intarray := []int{1, 2, 3}
593 sql.Register("sqlite3_TestCreateModuleEponymousOnly", &SQLiteDriver{
594 ConnectHook: func(conn *SQLiteConn) error {
595 return conn.CreateModule("test", testModuleEponymousOnly{t, intarray})
596 },
597 })
598 db, err := sql.Open("sqlite3_TestCreateModuleEponymousOnly", tempFilename)
599 if err != nil {
600 t.Fatalf("could not open db: %v", err)
601 }
602
603 var i, value int
604 rows, err := db.Query("SELECT rowid, * FROM test")
605 if err != nil {
606 t.Fatalf("couldn't select from virtual table: %v", err)
607 }
608 for rows.Next() {
609 err := rows.Scan(&i, &value)
610 if err != nil {
611 t.Fatal(err)
612 }
613 if intarray[i] != value {
614 t.Fatalf("want %v but %v", intarray[i], value)
615 }
616 }
617
618 _, err = db.Exec("DROP TABLE test")
619 if err != nil {
620 t.Logf("couldn't drop virtual table: %v", err)
621 }
622}

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected