From 9eec439d3547553303cf0b46e51f57de11760641 Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Sat, 19 Oct 2024 08:58:55 +0100 Subject: [PATCH] More tests. --- tests/db_test.go | 8 ++++++++ tests/parallel/parallel_test.go | 28 ++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/tests/db_test.go b/tests/db_test.go index 00a0f93..a10f01b 100644 --- a/tests/db_test.go +++ b/tests/db_test.go @@ -14,6 +14,7 @@ import ( _ "github.com/ncruces/go-sqlite3/vfs/adiantum" "github.com/ncruces/go-sqlite3/vfs/memdb" _ "github.com/ncruces/go-sqlite3/vfs/memdb" + _ "github.com/ncruces/go-sqlite3/vfs/xts" ) //go:embed testdata/wal.db @@ -76,6 +77,13 @@ func TestDB_adiantum(t *testing.T) { "&vfs=adiantum&textkey=correct+horse+battery+staple") } +func TestDB_xts(t *testing.T) { + t.Parallel() + tmp := filepath.Join(t.TempDir(), "test.db") + testDB(t, "file:"+filepath.ToSlash(tmp)+"?nolock=1"+ + "&vfs=xts&textkey=correct+horse+battery+staple") +} + func TestDB_nolock(t *testing.T) { t.Parallel() tmp := filepath.Join(t.TempDir(), "test.db") diff --git a/tests/parallel/parallel_test.go b/tests/parallel/parallel_test.go index 6f82410..836a3e2 100644 --- a/tests/parallel/parallel_test.go +++ b/tests/parallel/parallel_test.go @@ -20,6 +20,7 @@ import ( "github.com/ncruces/go-sqlite3/vfs" _ "github.com/ncruces/go-sqlite3/vfs/adiantum" "github.com/ncruces/go-sqlite3/vfs/memdb" + _ "github.com/ncruces/go-sqlite3/vfs/xts" ) func TestMain(m *testing.M) { @@ -100,9 +101,9 @@ func Test_adiantum(t *testing.T) { var iter int if testing.Short() { - iter = 1000 + iter = 500 } else { - iter = 5000 + iter = 2500 } name := "file:" + @@ -116,6 +117,29 @@ func Test_adiantum(t *testing.T) { testIntegrity(t, name) } +func Test_xts(t *testing.T) { + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } + + var iter int + if testing.Short() { + iter = 500 + } else { + iter = 2500 + } + + name := "file:" + + filepath.ToSlash(filepath.Join(t.TempDir(), "test.db")) + + "?vfs=xts" + + "&_pragma=hexkey(e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855)" + + "&_pragma=busy_timeout(10000)" + + "&_pragma=journal_mode(truncate)" + + "&_pragma=synchronous(off)" + testParallel(t, name, iter) + testIntegrity(t, name) +} + func TestMultiProcess(t *testing.T) { if !vfs.SupportsFileLocking { t.Skip("skipping without locks")