grafana/pkg/services/dashboardversion/dashvertest/fake.go
Kristin Laemmert 6e9419ea80
chore(dashboard version service): make method sigs more consistent (#60736)
The DashboardVersion struct is the database object; the DashboardVersionDTO is the object that should be sent to the API layer.

In the future I'd like to move DashboardVersion to dashverimpl and un-export it, but there are a few places that Insert directly into that table, not all of which are test fixtures, so that should wait until we clean up at least the DashboardService's use of it.
2022-12-27 11:17:24 -05:00

36 lines
1.2 KiB
Go

package dashvertest
import (
"context"
dashver "github.com/grafana/grafana/pkg/services/dashboardversion"
)
type FakeDashboardVersionService struct {
ExpectedDashboardVersion *dashver.DashboardVersionDTO
ExpectedDashboardVersions []*dashver.DashboardVersionDTO
ExpectedListDashboarVersions []*dashver.DashboardVersionDTO
counter int
ExpectedError error
}
func NewDashboardVersionServiceFake() *FakeDashboardVersionService {
return &FakeDashboardVersionService{}
}
func (f *FakeDashboardVersionService) Get(ctx context.Context, query *dashver.GetDashboardVersionQuery) (*dashver.DashboardVersionDTO, 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
}