2022-05-30 18:48:22 +00:00
|
|
|
package store
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"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-08 15:46:32 +00:00
|
|
|
db, migration, err := sqlite.NewDB(":memory:", false, utils.Logger())
|
2022-05-30 18:48:22 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2023-01-04 17:58:14 +00:00
|
|
|
dbStore, err := persistence.NewDBStore(utils.Logger(), persistence.WithDB(db), persistence.WithMigrations(migration))
|
2022-05-30 18:48:22 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return dbStore
|
|
|
|
}
|