]> Sergey Matveev's repositories - btrtrc.git/blobdiff - storage/sqlite/sqlite-storage_test.go
gorond test files
[btrtrc.git] / storage / sqlite / sqlite-storage_test.go
index 64ad836d3a3cb75447a66485e06e4c000747355f..d2f16af7ee0449911b3cb0ea855243d64244f14c 100644 (file)
@@ -12,15 +12,35 @@ import (
 
        _ "github.com/anacrolix/envpprof"
        "github.com/anacrolix/squirrel"
-       "github.com/anacrolix/torrent/storage"
-       test_storage "github.com/anacrolix/torrent/storage/test"
        "github.com/dustin/go-humanize"
        qt "github.com/frankban/quicktest"
+
+       "github.com/anacrolix/torrent/storage"
+       test_storage "github.com/anacrolix/torrent/storage/test"
+       "github.com/anacrolix/torrent/test"
 )
 
+func TestLeecherStorage(t *testing.T) {
+       test.TestLeecherStorage(t, test.LeecherStorageTestCase{
+               "SqliteDirect",
+               func(s string) storage.ClientImplCloser {
+                       path := filepath.Join(s, "sqlite3.db")
+                       var opts NewDirectStorageOpts
+                       opts.Path = path
+                       cl, err := NewDirectStorage(opts)
+                       if err != nil {
+                               panic(err)
+                       }
+                       return cl
+               },
+               0,
+       })
+}
+
 func BenchmarkMarkComplete(b *testing.B) {
        const pieceSize = test_storage.DefaultPieceSize
        const noTriggers = false
+       const noCacheBlobs = false
        var capacity int64 = test_storage.DefaultNumPieces * pieceSize / 2
        if noTriggers {
                // Since we won't push out old pieces, we have to mark them incomplete manually.
@@ -34,6 +54,7 @@ func BenchmarkMarkComplete(b *testing.B) {
                var opts squirrel.NewCacheOpts
                opts.Capacity = capacity
                opts.NoTriggers = noTriggers
+               opts.NoCacheBlobs = noCacheBlobs
                benchOpts := func(b *testing.B) {
                        opts.Path = filepath.Join(b.TempDir(), "storage.db")
                        ci, err := NewDirectStorage(opts)
@@ -49,13 +70,14 @@ func BenchmarkMarkComplete(b *testing.B) {
                                var opts NewDirectStorageOpts
                                opts.Memory = memory
                                opts.Capacity = capacity
-                               //opts.GcBlobs = true
+                               // opts.GcBlobs = true
                                opts.BlobFlushInterval = time.Second
                                opts.NoTriggers = noTriggers
+                               opts.NoCacheBlobs = noCacheBlobs
                                directBench := func(b *testing.B) {
                                        opts.Path = filepath.Join(b.TempDir(), "storage.db")
                                        ci, err := NewDirectStorage(opts)
-                                       var ujm squirrel.UnexpectedJournalMode
+                                       var ujm squirrel.ErrUnexpectedJournalMode
                                        if errors.As(err, &ujm) {
                                                b.Skipf("setting journal mode %q: %v", opts.SetJournalMode, err)
                                        }