Plugins: Separate manager read/write components (#50313)

* separate manager read/write

* guarantee consistency in test
This commit is contained in:
Will Browne
2022-06-07 17:51:00 +02:00
committed by GitHub
parent aa74371008
commit f7cce28cdf
5 changed files with 15 additions and 3 deletions
+3
View File
@@ -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)
})
}