mirror of
https://github.com/nkanaev/yarr.git
synced 2026-06-24 09:05:16 +00:00
rename package name + test factory
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package sqlite
|
||||
package tests
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package sqlite
|
||||
package tests
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package sqlite
|
||||
package tests
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package sqlite
|
||||
package tests
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package sqlite
|
||||
package tests
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
package sqlite
|
||||
package tests
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/nkanaev/yarr/src/storage"
|
||||
)
|
||||
|
||||
func testDB() *SQLiteStorage {
|
||||
log.SetOutput(io.Discard)
|
||||
db, err := New(":memory:")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
func dbtest(t *testing.T, testcase func(t *testing.T, db storage.Storage)) {
|
||||
testurls := map[string]string {
|
||||
"sqlite": ":memory:",
|
||||
"postgres": "postgres://postgres:postgres@localhost:5432/yarr_test",
|
||||
}
|
||||
log.SetOutput(os.Stderr)
|
||||
return db
|
||||
}
|
||||
|
||||
func TestStorage(t *testing.T) {
|
||||
db, err := New(":memory:")
|
||||
for testname, url := range testurls {
|
||||
db, err := storage.New(url)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Fatalf("failed to init storage for %s: %v", url, err)
|
||||
}
|
||||
if db == nil {
|
||||
t.Fatal("no db")
|
||||
t.Run(testname, func(t *testing.T) {
|
||||
testcase(t, db)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user