feat: abstract database drivers

This commit is contained in:
Steven
2023-12-17 13:56:41 +08:00
parent 6350b19478
commit 9173c8f19a
39 changed files with 1707 additions and 1356 deletions

View File

@ -15,11 +15,14 @@ import (
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)
dbDriver, err := db.NewDBDriver(profile)
if err != nil {
fmt.Printf("failed to create db driver, error: %+v\n", err)
}
if err := dbDriver.Migrate(ctx); err != nil {
fmt.Printf("failed to migrate db, error: %+v\n", err)
}
store := store.New(db.DBInstance, profile)
store := store.New(dbDriver, profile)
return store
}