mirror of
https://github.com/grafana/grafana.git
synced 2024-12-26 17:01:09 -06:00
6e9419ea80
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.
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.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
|
|
}
|