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"
|
|
|
|
|
2023-05-29 08:29:42 +03:00
|
|
|
// 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
|
|
|
|
}
|