sdk/hints: adapt sqlite to also support postgres.

This commit is contained in:
fiatjaf
2024-12-23 18:48:04 -03:00
parent 9aac901c03
commit 3b3d5cce7b
8 changed files with 109 additions and 41 deletions

View File

@@ -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)