File tree Expand file tree Collapse file tree 4 files changed +46
-12
lines changed Expand file tree Collapse file tree 4 files changed +46
-12
lines changed Original file line number Diff line number Diff line change @@ -16,10 +16,10 @@ import (
16
16
)
17
17
18
18
//go:embed testdata/wal.db
19
- var waldb []byte
19
+ var walDB []byte
20
20
21
21
//go:embed testdata/utf16be.db
22
- var utf16db []byte
22
+ var utf16DB []byte
23
23
24
24
func TestDB_memory (t * testing.T ) {
25
25
t .Parallel ()
@@ -42,7 +42,7 @@ func TestDB_wal(t *testing.T) {
42
42
43
43
t .Parallel ()
44
44
tmp := filepath .Join (t .TempDir (), "test.db" )
45
- err := os .WriteFile (tmp , waldb , 0666 )
45
+ err := os .WriteFile (tmp , walDB , 0666 )
46
46
if err != nil {
47
47
t .Fatal (err )
48
48
}
@@ -56,7 +56,7 @@ func TestDB_utf16(t *testing.T) {
56
56
57
57
t .Parallel ()
58
58
tmp := filepath .Join (t .TempDir (), "test.db" )
59
- err := os .WriteFile (tmp , utf16db , 0666 )
59
+ err := os .WriteFile (tmp , utf16DB , 0666 )
60
60
if err != nil {
61
61
t .Fatal (err )
62
62
}
Original file line number Diff line number Diff line change @@ -26,19 +26,19 @@ func TestWAL_enter_exit(t *testing.T) {
26
26
defer db .Close ()
27
27
28
28
if ! vfs .SupportsSharedMemory {
29
- err = db .Exec (`PRAGMA locking_mode=EXCLUSIVE ` )
29
+ err = db .Exec (`PRAGMA locking_mode=exclusive ` )
30
30
if err != nil {
31
31
t .Fatal (err )
32
32
}
33
33
}
34
34
35
35
err = db .Exec (`
36
36
CREATE TABLE test (col);
37
- PRAGMA journal_mode=WAL ;
37
+ PRAGMA journal_mode=wal ;
38
38
SELECT * FROM test;
39
- PRAGMA journal_mode=DELETE ;
39
+ PRAGMA journal_mode=delete ;
40
40
SELECT * FROM test;
41
- PRAGMA journal_mode=WAL ;
41
+ PRAGMA journal_mode=wal ;
42
42
SELECT * FROM test;
43
43
` )
44
44
if err != nil {
@@ -53,7 +53,7 @@ func TestWAL_readonly(t *testing.T) {
53
53
t .Parallel ()
54
54
55
55
tmp := filepath .Join (t .TempDir (), "test.db" )
56
- err := os .WriteFile (tmp , waldb , 0666 )
56
+ err := os .WriteFile (tmp , walDB , 0666 )
57
57
if err != nil {
58
58
t .Fatal (err )
59
59
}
@@ -101,8 +101,8 @@ func TestConn_WalCheckpoint(t *testing.T) {
101
101
})
102
102
103
103
err = db .Exec (`
104
- PRAGMA locking_mode=EXCLUSIVE ;
105
- PRAGMA journal_mode=WAL ;
104
+ PRAGMA locking_mode=exlusive ;
105
+ PRAGMA journal_mode=wal ;
106
106
CREATE TABLE test (col);
107
107
` )
108
108
if err != nil {
Original file line number Diff line number Diff line change 1
1
package adiantum_test
2
2
3
3
import (
4
+ _ "embed"
4
5
"path/filepath"
6
+ "strings"
5
7
"testing"
6
8
7
9
"github.com/ncruces/go-sqlite3"
10
+ "github.com/ncruces/go-sqlite3/driver"
8
11
_ "github.com/ncruces/go-sqlite3/embed"
9
- _ "github.com/ncruces/go-sqlite3/vfs/adiantum"
12
+ "github.com/ncruces/go-sqlite3/util/ioutil"
13
+ "github.com/ncruces/go-sqlite3/vfs"
14
+ "github.com/ncruces/go-sqlite3/vfs/adiantum"
15
+ "github.com/ncruces/go-sqlite3/vfs/readervfs"
10
16
)
11
17
18
+ //go:embed testdata/test.db
19
+ var testDB string
20
+
21
+ func Test_fileformat (t * testing.T ) {
22
+ readervfs .Create ("test.db" , ioutil .NewSizeReaderAt (strings .NewReader (testDB )))
23
+ adiantum .Register ("adiantum" , vfs .Find ("reader" ), nil )
24
+
25
+ db , err := driver .Open ("file:test.db?vfs=adiantum" , nil )
26
+ if err != nil {
27
+ t .Fatal (err )
28
+ }
29
+ defer db .Close ()
30
+
31
+ _ , err = db .Exec (`PRAGMA textkey='correct+horse+battery+staple'` )
32
+ if err != nil {
33
+ t .Fatal (err )
34
+ }
35
+
36
+ var version uint32
37
+ err = db .QueryRow (`PRAGMA user_version` ).Scan (& version )
38
+ if err != nil {
39
+ t .Fatal (err )
40
+ }
41
+ if version != 0xBADDB {
42
+ t .Error (version )
43
+ }
44
+ }
45
+
12
46
func Benchmark_nokey (b * testing.B ) {
13
47
tmp := filepath .Join (b .TempDir (), "test.db" )
14
48
sqlite3 .Initialize ()
You can’t perform that action at this time.
0 commit comments