Plugins: Make it possible to support multiple plugin versions (#82116)
* first pass * use version in more places * add comment * update installer * fix wire * fix tests * tidy * simplify changes * fix in mem * remove unused step * fix step dupe logic for child plugins + add tests
This commit is contained in:
@@ -23,6 +23,8 @@ func TestPluginManager_Add_Remove(t *testing.T) {
|
||||
const (
|
||||
pluginID, v1 = "test-panel", "1.0.0"
|
||||
zipNameV1 = "test-panel-1.0.0.zip"
|
||||
v2 = "2.0.0"
|
||||
zipNameV2 = "test-panel-2.0.0.zip"
|
||||
)
|
||||
|
||||
// mock a plugin to be returned automatically by the plugin loader
|
||||
@@ -83,10 +85,6 @@ func TestPluginManager_Add_Remove(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Update plugin to different version", func(t *testing.T) {
|
||||
const (
|
||||
v2 = "2.0.0"
|
||||
zipNameV2 = "test-panel-2.0.0.zip"
|
||||
)
|
||||
// mock a plugin to be returned automatically by the plugin loader
|
||||
pluginV2 := createPlugin(t, pluginID, plugins.ClassExternal, true, true, func(plugin *plugins.Plugin) {
|
||||
plugin.Info.Version = v2
|
||||
@@ -138,7 +136,7 @@ func TestPluginManager_Add_Remove(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err = inst.Remove(context.Background(), pluginID)
|
||||
err = inst.Remove(context.Background(), pluginID, v2)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, []string{pluginID}, unloadedPlugins)
|
||||
@@ -146,7 +144,7 @@ func TestPluginManager_Add_Remove(t *testing.T) {
|
||||
t.Run("Won't remove if not exists", func(t *testing.T) {
|
||||
inst.pluginRegistry = fakes.NewFakePluginRegistry()
|
||||
|
||||
err = inst.Remove(context.Background(), pluginID)
|
||||
err = inst.Remove(context.Background(), pluginID, v2)
|
||||
require.Equal(t, plugins.ErrPluginNotInstalled, err)
|
||||
})
|
||||
})
|
||||
@@ -179,7 +177,7 @@ func TestPluginManager_Add_Remove(t *testing.T) {
|
||||
require.Equal(t, plugins.ErrInstallCorePlugin, err)
|
||||
|
||||
t.Run(fmt.Sprintf("Can't uninstall %s plugin", tc.class), func(t *testing.T) {
|
||||
err = pm.Remove(context.Background(), p.ID)
|
||||
err = pm.Remove(context.Background(), p.ID, p.Info.Version)
|
||||
require.Equal(t, plugins.ErrUninstallCorePlugin, err)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user