memos/test/store/store.go

26 lines
501 B
Go
Raw Normal View History

2023-04-03 04:53:36 +03:00
package teststore
2023-04-01 17:47:19 +03:00
import (
"context"
"fmt"
"testing"
"github.com/usememos/memos/store"
"github.com/usememos/memos/store/db"
"github.com/usememos/memos/test"
// sqlite driver.
_ "modernc.org/sqlite"
2023-04-01 17:47:19 +03:00
)
func NewTestingStore(ctx context.Context, t *testing.T) *store.Store {
profile := test.GetTestingProfile(t)
db := db.NewDB(profile)
if err := db.Open(ctx); err != nil {
fmt.Printf("failed to open db, error: %+v\n", err)
}
store := store.New(db.DBInstance, profile)
return store
}