-
Notifications
You must be signed in to change notification settings - Fork 24
/
sql_test.go
36 lines (29 loc) · 849 Bytes
/
sql_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package sqlite3
import (
"bytes"
"encoding/gob"
"testing"
)
func TestGeneral(t *testing.T) {
Initialize()
defer Shutdown()
t.Logf("Sqlite3 Version: %v\n", LibVersion())
filename := ":memory:"
db, e := Open(filename)
fatalOnError(t, e, "opening %v", filename)
defer db.Close()
t.Logf("Database opened: %v [flags: %v]", db.Filename, db.DBFlag)
t.Logf("Returning status: %v", e)
}
func TestBlob(t *testing.T) {
Session("test.db", func(db *Database) {
BAR.Drop(db)
BAR.Create(db)
buffer := new(bytes.Buffer)
encoder := gob.NewEncoder(buffer)
fatalOnError(t, encoder.Encode(TwoItems{ "holy", "moly guacomole" }), "Encoding failed: buffer = %v", buffer)
t.Logf("Encoded data: %v", buffer.Bytes())
db.runQuery(t, "INSERT INTO bar values (?, ?)", 1, TwoItems{ "holy moly", "guacomole" })
db.stepThroughRows(t, BAR)
})
}