rename package name + test factory

This commit is contained in:
nkanaev
2026-06-14 14:33:59 +01:00
parent a5b8e62ca7
commit 32cfc3bc1a
6 changed files with 20 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
package sqlite package tests
import ( import (
"reflect" "reflect"

View File

@@ -1,4 +1,4 @@
package sqlite package tests
import ( import (
"testing" "testing"

View File

@@ -1,4 +1,4 @@
package sqlite package tests
import ( import (
"testing" "testing"

View File

@@ -1,4 +1,4 @@
package sqlite package tests
import ( import (
"database/sql" "database/sql"

View File

@@ -1,4 +1,4 @@
package sqlite package tests
import ( import (
"reflect" "reflect"

View File

@@ -1,28 +1,26 @@
package sqlite package tests
import ( import (
"io" "io"
"log" "log"
"os" "os"
"testing" "testing"
"github.com/nkanaev/yarr/src/storage"
) )
func testDB() *SQLiteStorage { func dbtest(t *testing.T, testcase func(t *testing.T, db storage.Storage)) {
log.SetOutput(io.Discard) testurls := map[string]string {
db, err := New(":memory:") "sqlite": ":memory:",
if err != nil { "postgres": "postgres://postgres:postgres@localhost:5432/yarr_test",
panic(err)
} }
log.SetOutput(os.Stderr) for testname, url := range testurls {
return db db, err := storage.New(url)
} if err != nil {
t.Fatalf("failed to init storage for %s: %v", url, err)
func TestStorage(t *testing.T) { }
db, err := New(":memory:") t.Run(testname, func(t *testing.T) {
if err != nil { testcase(t, db)
t.Fatal(err) })
}
if db == nil {
t.Fatal("no db")
} }
} }