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 (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package sqlite
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package sqlite
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package sqlite
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package sqlite
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|||||||
@@ -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")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user