fix(34): WR-10 align the marketplace compatibility marker with plugin:install
With a framework version that is not a release (a devel build, an empty FrameworkVersion) every plugin with a minimum was marked as needing a newer framework, and Compatible looked only at the newest release, so a plugin whose older release fits was marked although plugin:install would install that release. An unknown framework now gives no marker (and no needs-framework note on the Installed tab), and a plugin whose newest release is too new is looked up (cached, four at a time) and counts as compatible when an older release fits.
This commit is contained in:
@@ -377,6 +377,51 @@ func TestPluginsEndpoints(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("marketplace compatibility", func(t *testing.T) {
|
||||
list := []kiosk.RegistryPlugin{
|
||||
{ID: "acme.shop", Name: "Shop", LatestVersion: "v1.0.0", LatestFramework: "v0.9.0"},
|
||||
{ID: "acme.old", Name: "Old", LatestVersion: "v0.3.0", LatestFramework: "v0.9.0"},
|
||||
{ID: "acme.blog", Name: "Blog", LatestVersion: "v0.2.0", LatestFramework: "v0.6.0"},
|
||||
}
|
||||
versions := map[string][]kiosk.RegistryVersion{
|
||||
"acme.shop": {rel("v1.0.0", "v0.9.0"), rel("v0.9.0", "v0.8.0")},
|
||||
"acme.old": {rel("v0.3.0", "v0.9.0"), rel("v0.1.0", "v0.5.0")},
|
||||
}
|
||||
compat := func(t *testing.T, framework string) (map[string]bool, *memPluginRegistry) {
|
||||
t.Helper()
|
||||
reg := &memPluginRegistry{list: list, versions: versions}
|
||||
installed := testInstalled()
|
||||
installed.Framework = framework
|
||||
svc := unitPluginsService(t, installed, reg, clock)
|
||||
got := map[string]bool{}
|
||||
for _, p := range decodeMarketplace(t, pluginsCall(svc, (*service).pluginsMarketplace, pluginsViewer, "/plugins/marketplace")).Data {
|
||||
got[p.ID] = p.Compatible
|
||||
}
|
||||
return got, reg
|
||||
}
|
||||
// A release framework: an older compatible release counts, as it
|
||||
// does for plugin:install; only the incompatible are looked up.
|
||||
got, reg := compat(t, "v0.6.0")
|
||||
if got["acme.shop"] || !got["acme.old"] || !got["acme.blog"] {
|
||||
t.Errorf("v0.6.0: %v", got)
|
||||
}
|
||||
if reg.count("versions acme.blog") != 0 {
|
||||
t.Error("a compatible plugin was looked up")
|
||||
}
|
||||
// A framework that is not a release cannot be judged: no marker.
|
||||
for _, fw := range []string{"(devel)", "", "abc1234"} {
|
||||
got, reg := compat(t, fw)
|
||||
if !got["acme.shop"] || !got["acme.old"] || !got["acme.blog"] || reg.count("versions") != 0 {
|
||||
t.Errorf("%q: %v", fw, got)
|
||||
}
|
||||
}
|
||||
p := InstalledPlugin{ID: "acme.blog", Version: "v0.1.0"}
|
||||
applyUpdate(&p, []kiosk.RegistryVersion{rel("v0.3.0", "v0.7.0")}, frameworkRelease("(devel)"))
|
||||
if p.LatestFramework != "" || p.UpdateAvailable {
|
||||
t.Errorf("devel framework marks the installed plugin: %+v", p)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("marketplace", func(t *testing.T) {
|
||||
reg := &memPluginRegistry{list: []kiosk.RegistryPlugin{
|
||||
{ID: "acme.blog", Name: "Blog", Category: "content", LatestVersion: "v0.2.0", LatestFramework: "v0.6.0", IconURL: "https://cdn.example.test/blog.png"},
|
||||
|
||||
Reference in New Issue
Block a user