grafana/pkg/api/fakes.go
Will Browne 2e3e7a7e55
Plugins: Plugin Store API returns DTO model (#41340)
* toying around

* fix refs

* remove unused fields

* go further

* add context

* ensure streaming handler is set
2021-11-17 12:04:22 +01:00

51 lines
948 B
Go

package api
import (
"context"
"github.com/grafana/grafana/pkg/plugins"
)
type fakePluginStore struct {
plugins.Store
plugins map[string]plugins.PluginDTO
}
func (pr fakePluginStore) Plugin(_ context.Context, pluginID string) (plugins.PluginDTO, bool) {
p, exists := pr.plugins[pluginID]
return p, exists
}
func (pr fakePluginStore) Plugins(_ context.Context, pluginTypes ...plugins.Type) []plugins.PluginDTO {
var result []plugins.PluginDTO
for _, v := range pr.plugins {
for _, t := range pluginTypes {
if v.Type == t {
result = append(result, v)
}
}
}
return result
}
type fakeRendererManager struct {
plugins.RendererManager
}
func (ps *fakeRendererManager) Renderer() *plugins.Plugin {
return nil
}
type fakePluginStaticRouteResolver struct {
plugins.StaticRouteResolver
routes []*plugins.StaticRoute
}
func (psrr *fakePluginStaticRouteResolver) Routes() []*plugins.StaticRoute {
return psrr.routes
}