grafana/pkg/infra/db/dbtest/dbtest.go
Kristin Laemmert 05709ce411
chore: remove sqlstore & mockstore dependencies from (most) packages (#57087)
* chore: add alias for InitTestDB and Session

Adds an alias for the sqlstore InitTestDB and Session, and updates tests using these to reduce dependencies on the sqlstore.Store.

* next pass of removing sqlstore imports
* last little bit
* remove mockstore where possible
2022-10-19 09:02:15 -04:00

54 lines
1.3 KiB
Go

package dbtest
import (
"context"
"xorm.io/core"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
"github.com/grafana/grafana/pkg/services/sqlstore/session"
)
type FakeDB struct {
ExpectedError error
}
func NewFakeDB() *FakeDB {
return &FakeDB{}
}
func (f *FakeDB) WithTransactionalDbSession(ctx context.Context, callback sqlstore.DBTransactionFunc) error {
return f.ExpectedError
}
func (f *FakeDB) WithDbSession(ctx context.Context, callback sqlstore.DBTransactionFunc) error {
return f.ExpectedError
}
func (f *FakeDB) WithNewDbSession(ctx context.Context, callback sqlstore.DBTransactionFunc) error {
return f.ExpectedError
}
func (f *FakeDB) InTransaction(ctx context.Context, fn func(ctx context.Context) error) error {
return f.ExpectedError
}
func (f *FakeDB) GetDBType() core.DbType {
return ""
}
func (f *FakeDB) GetDialect() migrator.Dialect {
return nil
}
func (f *FakeDB) GetSqlxSession() *session.SessionDB {
return nil
}
// TODO: service-specific methods not yet split out ; to be removed
func (f *FakeDB) UpdateTempUserWithEmailSent(ctx context.Context, cmd *models.UpdateTempUserWithEmailSentCommand) error {
return f.ExpectedError
}