Skip to content

Commit c6a9868

Browse files
committed
Blob I/O: use raw connection
1 parent 88d6cfd commit c6a9868

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

blob_io_test.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,34 @@ package sqlite3
1010

1111
import (
1212
"bytes"
13+
"context"
1314
"database/sql"
1415
"io"
1516
"testing"
1617
)
1718

1819
func TestBlobIO(t *testing.T) {
19-
driverName := "sqlite3_TestBlobIO2"
20-
var driverConn *SQLiteConn
21-
sql.Register(driverName, &SQLiteDriver{
22-
ConnectHook: func(conn *SQLiteConn) error {
23-
driverConn = conn
24-
return nil
25-
}})
26-
27-
db, err := sql.Open(driverName, ":memory:")
20+
db, err := sql.Open("sqlite3", "file:testblobio?mode=memory&cache=shared")
2821
if err != nil {
2922
t.Fatal("Fail to open:", err)
3023
}
3124
defer db.Close()
3225

26+
conn, err := db.Conn(context.Background())
27+
if err != nil {
28+
t.Fatal("Failed to get raw connection:", err)
29+
}
30+
defer conn.Close()
31+
32+
var driverConn *SQLiteConn
33+
err = conn.Raw(func(conn interface{}) error {
34+
driverConn = conn.(*SQLiteConn)
35+
return nil
36+
})
37+
if err != nil {
38+
t.Fatal("Failed to get raw connection:", err)
39+
}
40+
3341
// Test data
3442
expected := []byte("I ❤️ SQLite in \x00\x01\x02…")
3543
rowid := int64(6581)

0 commit comments

Comments
 (0)