store.go 511 B

12345678910111213141516171819202122232425
  1. package teststore
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "github.com/usememos/memos/store"
  7. "github.com/usememos/memos/store/db"
  8. "github.com/usememos/memos/test"
  9. // sqlite3 driver.
  10. _ "github.com/mattn/go-sqlite3"
  11. )
  12. func NewTestingStore(ctx context.Context, t *testing.T) *store.Store {
  13. profile := test.GetTestingProfile(t)
  14. db := db.NewDB(profile)
  15. if err := db.Open(ctx); err != nil {
  16. fmt.Printf("failed to open db, error: %+v\n", err)
  17. }
  18. store := store.New(db.DBInstance, profile)
  19. return store
  20. }