2024-05-03 16:07:03 +00:00
|
|
|
package legacy_store
|
2022-05-30 18:48:22 +00:00
|
|
|
|
|
|
|
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-11-09 20:10:40 +00:00
|
|
|
db, err := sqlite.NewDB(":memory:", 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
|
|
|
|
}
|