mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
* Split GetDashboarVersions method * Add sqlstore dialect and tests * Fix signature of PAtchPreference * Add GetDialect to sqlstore and remove GetDashboardVersions * Add GetDialect to db interface * Implement List * add deleted test function * Remove GetDialect from sqlstore interface * Remove deleted method from mock * Refactor test
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package dashvertest
|
|
|
|
import (
|
|
"context"
|
|
|
|
dashver "github.com/grafana/grafana/pkg/services/dashboardversion"
|
|
)
|
|
|
|
type FakeDashboardVersionService struct {
|
|
ExpectedDashboardVersion *dashver.DashboardVersion
|
|
ExpectedDashboardVersions []*dashver.DashboardVersion
|
|
ExpectedListDashboarVersions []*dashver.DashboardVersionDTO
|
|
counter int
|
|
ExpectedError error
|
|
}
|
|
|
|
func NewDashboardVersionServiceFake() *FakeDashboardVersionService {
|
|
return &FakeDashboardVersionService{}
|
|
}
|
|
|
|
func (f *FakeDashboardVersionService) Get(ctx context.Context, query *dashver.GetDashboardVersionQuery) (*dashver.DashboardVersion, error) {
|
|
if len(f.ExpectedDashboardVersions) == 0 {
|
|
return f.ExpectedDashboardVersion, f.ExpectedError
|
|
}
|
|
f.counter++
|
|
return f.ExpectedDashboardVersions[f.counter-1], f.ExpectedError
|
|
}
|
|
|
|
func (f *FakeDashboardVersionService) DeleteExpired(ctx context.Context, cmd *dashver.DeleteExpiredVersionsCommand) error {
|
|
return f.ExpectedError
|
|
}
|
|
|
|
func (f *FakeDashboardVersionService) List(ctx context.Context, query *dashver.ListDashboardVersionsQuery) ([]*dashver.DashboardVersionDTO, error) {
|
|
return f.ExpectedListDashboarVersions, f.ExpectedError
|
|
}
|