mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-27 14:22:20 +02:00
sdk/hints: adapt sqlite to also support postgres.
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/nbd-wtf/go-nostr/sdk/hints/sqlite"
|
||||
"github.com/nbd-wtf/go-nostr/sdk/hints/sqlh"
|
||||
"github.com/stretchr/testify/require"
|
||||
_ "github.com/tursodatabase/go-libsql"
|
||||
)
|
||||
@@ -16,12 +16,12 @@ func TestSQLiteHintsLibsql(t *testing.T) {
|
||||
path := "/tmp/tmpsdkhintssqlite"
|
||||
os.RemoveAll(path)
|
||||
|
||||
db, err := sqlx.Connect("libsql", "file://"+path)
|
||||
db, err := sql.Open("libsql", "file://"+path)
|
||||
|
||||
require.NoError(t, err, "failed to create sqlitehints db")
|
||||
db.SetMaxOpenConns(1)
|
||||
|
||||
sh, err := sqlite.NewSQLiteHints(db)
|
||||
sh, err := sqlh.NewSQLHints(db, "sqlite3")
|
||||
require.NoError(t, err, "failed to setup sqlitehints db")
|
||||
|
||||
runTestWith(t, sh)
|
||||
|
@@ -3,12 +3,12 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/nbd-wtf/go-nostr/sdk/hints/sqlite"
|
||||
"github.com/nbd-wtf/go-nostr/sdk/hints/sqlh"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -16,12 +16,12 @@ func TestSQLiteHintsMattn(t *testing.T) {
|
||||
path := "/tmp/tmpsdkhintssqlite"
|
||||
os.RemoveAll(path)
|
||||
|
||||
db, err := sqlx.Connect("sqlite3", path)
|
||||
db, err := sql.Open("sqlite3", path)
|
||||
|
||||
require.NoError(t, err, "failed to create sqlitehints db")
|
||||
db.SetMaxOpenConns(1)
|
||||
|
||||
sh, err := sqlite.NewSQLiteHints(db)
|
||||
sh, err := sqlh.NewSQLHints(db, "sqlite3")
|
||||
require.NoError(t, err, "failed to setup sqlitehints db")
|
||||
|
||||
runTestWith(t, sh)
|
||||
|
@@ -3,9 +3,9 @@ package test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr/sdk/hints/memory"
|
||||
"github.com/nbd-wtf/go-nostr/sdk/hints/memoryh"
|
||||
)
|
||||
|
||||
func TestMemoryHints(t *testing.T) {
|
||||
runTestWith(t, memory.NewHintDB())
|
||||
runTestWith(t, memoryh.NewHintDB())
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/nbd-wtf/go-nostr/sdk/hints/sqlite"
|
||||
"github.com/nbd-wtf/go-nostr/sdk/hints/sqlh"
|
||||
"github.com/stretchr/testify/require"
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
@@ -14,12 +14,12 @@ func TestSQLiteHintsModernC(t *testing.T) {
|
||||
path := "/tmp/tmpsdkhintssqlite"
|
||||
os.RemoveAll(path)
|
||||
|
||||
db, err := sqlx.Connect("sqlite", path)
|
||||
db, err := sql.Open("sqlite", path)
|
||||
|
||||
require.NoError(t, err, "failed to create sqlitehints db")
|
||||
db.SetMaxOpenConns(1)
|
||||
|
||||
sh, err := sqlite.NewSQLiteHints(db)
|
||||
sh, err := sqlh.NewSQLHints(db, "sqlite3")
|
||||
require.NoError(t, err, "failed to setup sqlitehints db")
|
||||
|
||||
runTestWith(t, sh)
|
||||
|
@@ -3,11 +3,11 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/nbd-wtf/go-nostr/sdk/hints/sqlite"
|
||||
"github.com/nbd-wtf/go-nostr/sdk/hints/sqlh"
|
||||
_ "github.com/ncruces/go-sqlite3/driver"
|
||||
_ "github.com/ncruces/go-sqlite3/embed"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -17,12 +17,12 @@ func TestSQLiteHintsNcruces(t *testing.T) {
|
||||
path := "/tmp/tmpsdkhintssqlite"
|
||||
os.RemoveAll(path)
|
||||
|
||||
db, err := sqlx.Connect("sqlite3", path)
|
||||
db, err := sql.Open("sqlite3", path)
|
||||
|
||||
require.NoError(t, err, "failed to create sqlitehints db")
|
||||
db.SetMaxOpenConns(1)
|
||||
|
||||
sh, err := sqlite.NewSQLiteHints(db)
|
||||
sh, err := sqlh.NewSQLHints(db, "sqlite3")
|
||||
require.NoError(t, err, "failed to setup sqlitehints db")
|
||||
|
||||
runTestWith(t, sh)
|
||||
|
Reference in New Issue
Block a user