e94d0c1b96
* make eval.Evaluator an interface * inject Evaluator to TestingApiSrv * move conditionEval to RouteTestGrafanaRuleConfig because it is the only place where it is used * update rule test api to check data source permissions
32 lines
832 B
Go
32 lines
832 B
Go
package datasources
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
type FakeCacheService struct {
|
|
DataSources []*models.DataSource
|
|
}
|
|
|
|
var _ CacheService = &FakeCacheService{}
|
|
|
|
func (c *FakeCacheService) GetDatasource(ctx context.Context, datasourceID int64, user *models.SignedInUser, skipCache bool) (*models.DataSource, error) {
|
|
for _, datasource := range c.DataSources {
|
|
if datasource.Id == datasourceID {
|
|
return datasource, nil
|
|
}
|
|
}
|
|
return nil, models.ErrDataSourceNotFound
|
|
}
|
|
|
|
func (c *FakeCacheService) GetDatasourceByUID(ctx context.Context, datasourceUID string, user *models.SignedInUser, skipCache bool) (*models.DataSource, error) {
|
|
for _, datasource := range c.DataSources {
|
|
if datasource.Uid == datasourceUID {
|
|
return datasource, nil
|
|
}
|
|
}
|
|
return nil, models.ErrDataSourceNotFound
|
|
}
|