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

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