feat: add user store tests

This commit is contained in:
Steven
2023-06-20 20:04:40 +08:00
parent 92d50eabf3
commit c3ce03ffe5
10 changed files with 118 additions and 169 deletions

25
test/store/store.go Normal file
View File

@ -0,0 +1,25 @@
package teststore
import (
"context"
"fmt"
"testing"
"github.com/boojack/shortify/store"
"github.com/boojack/shortify/store/db"
test "github.com/boojack/shortify/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(ctx); err != nil {
fmt.Printf("failed to open db, error: %+v\n", err)
}
store := store.New(db.DBInstance, profile)
return store
}