mirror of
https://github.com/usememos/memos.git
synced 2024-11-17 20:25:46 +08:00
28 lines
598 B
Go
28 lines
598 B
Go
package teststore
|
|
|
|
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"
|
|
)
|
|
|
|
func NewTestingStore(ctx context.Context, t *testing.T) *store.Store {
|
|
profile := test.GetTestingProfile(t)
|
|
db := db.NewDB(profile)
|
|
if err := db.Open(); err != nil {
|
|
fmt.Printf("failed to open db, error: %+v\n", err)
|
|
}
|
|
if err := db.Migrate(ctx); err != nil {
|
|
fmt.Printf("failed to migrate db, error: %+v\n", err)
|
|
}
|
|
|
|
store := store.New(db.DBInstance, profile)
|
|
return store
|
|
}
|