3
0
mirror of https://github.com/grafana/grafana.git synced 2025-02-25 18:55:37 -06:00
grafana/pkg/services/datasources/fakes/fake_cache_service.go
idafurjes 6afad51761
Move SignedInUser to user service and RoleType and Roles to org ()
* Move SignedInUser to user service and RoleType and Roles to org

* Use go naming convention for roles

* Fix some imports and leftovers

* Fix ldap debug test

* Fix lint

* Fix lint 2

* Fix lint 3

* Fix type and not needed conversion

* Clean up messages in api tests

* Clean up api tests 2
2022-08-10 11:56:48 +02:00

33 lines
927 B
Go

package datasources
import (
"context"
"github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/user"
)
type FakeCacheService struct {
DataSources []*datasources.DataSource
}
var _ datasources.CacheService = &FakeCacheService{}
func (c *FakeCacheService) GetDatasource(ctx context.Context, datasourceID int64, user *user.SignedInUser, skipCache bool) (*datasources.DataSource, error) {
for _, datasource := range c.DataSources {
if datasource.Id == datasourceID {
return datasource, nil
}
}
return nil, datasources.ErrDataSourceNotFound
}
func (c *FakeCacheService) GetDatasourceByUID(ctx context.Context, datasourceUID string, user *user.SignedInUser, skipCache bool) (*datasources.DataSource, error) {
for _, datasource := range c.DataSources {
if datasource.Uid == datasourceUID {
return datasource, nil
}
}
return nil, datasources.ErrDataSourceNotFound
}