mirror of
https://github.com/grafana/grafana.git
synced 2026-08-11 05:34:53 -05:00
Plugins: Separate manager read/write components (#50313)
* separate manager read/write * guarantee consistency in test
This commit is contained in:
@@ -15,6 +15,9 @@ type Store interface {
|
||||
Plugin(ctx context.Context, pluginID string) (PluginDTO, bool)
|
||||
// Plugins returns plugins by their requested type.
|
||||
Plugins(ctx context.Context, pluginTypes ...Type) []PluginDTO
|
||||
}
|
||||
|
||||
type Manager interface {
|
||||
// Add adds a plugin to the store.
|
||||
Add(ctx context.Context, pluginID, version string) error
|
||||
// Remove removes a plugin from the store.
|
||||
|
||||
@@ -3,6 +3,7 @@ package registry
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -213,6 +214,11 @@ func TestInMemory_Plugins(t *testing.T) {
|
||||
store: tt.mocks.store,
|
||||
}
|
||||
result := i.Plugins(context.Background())
|
||||
|
||||
// to ensure we can compare with expected
|
||||
sort.SliceStable(result, func(i, j int) bool {
|
||||
return result[i].ID < result[j].ID
|
||||
})
|
||||
require.Equal(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user