2022-05-30 18:48:22 +00:00
|
|
|
package store
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"testing"
|
|
|
|
|
2023-08-16 01:40:00 +00:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
2022-05-30 18:48:22 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2022-11-09 19:53:01 +00:00
|
|
|
"github.com/waku-org/go-waku/waku/persistence"
|
|
|
|
"github.com/waku-org/go-waku/waku/persistence/sqlite"
|
|
|
|
"github.com/waku-org/go-waku/waku/v2/utils"
|
2022-05-30 18:48:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func MemoryDB(t *testing.T) *persistence.DBStore {
|
|
|
|
var db *sql.DB
|
2023-08-09 17:23:44 +00:00
|
|
|
db, err := sqlite.NewDB(":memory:", false, utils.Logger())
|
2022-05-30 18:48:22 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2023-08-16 01:40:00 +00:00
|
|
|
dbStore, err := persistence.NewDBStore(prometheus.DefaultRegisterer, utils.Logger(), persistence.WithDB(db), persistence.WithMigrations(sqlite.Migrations))
|
2022-05-30 18:48:22 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return dbStore
|
|
|
|
}
|