fix(34): CR-01 never move a pseudo-version install back to its base release
plugin:update dropped a go.mod require that was not a strict vX.Y.Z and treated it as v0.0.0, so a module at a commit after v0.4.0 (v0.4.1-0.<ts>-<hash>) was moved back to v0.4.0. kiosk.Newer now places a release against a release, a git describe string or a pseudo-version (by the tag it builds on, in Go's version order); plugin:update and the admin Plugins screen badge share it. A pseudo-version with no tag before its commit is left alone with a note naming go get <module>@<tag>.
This commit is contained in:
@@ -377,3 +377,64 @@ func TestAskToProceed(t *testing.T) {
|
||||
t.Errorf("accepted: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestUpdatePseudoVersion pins CR-01: a module required at a
|
||||
// pseudo-version (a commit after a release, as go get M@main leaves it) is
|
||||
// never moved to the release it builds on or an older one, and one with no
|
||||
// release before its commit is not moved at all.
|
||||
func TestUpdatePseudoVersion(t *testing.T) {
|
||||
const after040 = "v0.4.1-0.20261001120000-abcdef123456"
|
||||
plan := func(t *testing.T, installed string, releases ...string) (string, error) {
|
||||
t.Helper()
|
||||
reg := &memRegistry{}
|
||||
reg.add("acme.blog", nil, releases...)
|
||||
app := installApp(t, "v0.6.0", map[string]string{"acme.blog": installed})
|
||||
var out bytes.Buffer
|
||||
err := Update(t.Context(), UpdateOptions{
|
||||
StartDir: app, ID: "acme.blog", Registry: reg, Out: &out, Interactive: true,
|
||||
Confirm: func(string) (bool, error) { return false, nil },
|
||||
})
|
||||
return out.String(), err
|
||||
}
|
||||
|
||||
t.Run("only the base release and older", func(t *testing.T) {
|
||||
out, err := plan(t, after040, "v0.4.0:v0.6.0", "v0.3.0:v0.6.0")
|
||||
if err != nil {
|
||||
t.Fatalf("update: %v\n%s", err, out)
|
||||
}
|
||||
if !strings.Contains(out, "Nothing to update.") || !strings.Contains(out, "up to date at "+after040) || strings.Contains(out, "-> v0.4.0") {
|
||||
t.Errorf("a commit after v0.4.0 is moved back:\n%s", out)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("a newer release", func(t *testing.T) {
|
||||
out, err := plan(t, after040, "v0.4.1:v0.6.0", "v0.4.0:v0.6.0")
|
||||
if !errors.Is(err, ErrCancelled) {
|
||||
t.Fatalf("update: %v\n%s", err, out)
|
||||
}
|
||||
if !strings.Contains(out, "acme.blog "+after040+" -> v0.4.1 (module)") {
|
||||
t.Errorf("plan:\n%s", out)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("no release before the commit", func(t *testing.T) {
|
||||
out, err := plan(t, "v0.0.0-20261001120000-abcdef123456", "v0.1.0:v0.6.0")
|
||||
if err != nil {
|
||||
t.Fatalf("update: %v\n%s", err, out)
|
||||
}
|
||||
if !strings.Contains(out, "Nothing to update.") || !strings.Contains(out, "plugin:update does not guess") || !strings.Contains(out, "go get example.test/blog@<tag>") {
|
||||
t.Errorf("an unplaceable commit is moved:\n%s", out)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("a requirement at a pseudo-version", func(t *testing.T) {
|
||||
reg := &memRegistry{}
|
||||
reg.add("acme.shop", kiosk.Requires{"acme.user": "v0.1.2"}, "v0.1.0:v0.6.0")
|
||||
app := installApp(t, "v0.6.0", map[string]string{"acme.user": "v0.1.3-0.20261001120000-abcdef123456"})
|
||||
var out bytes.Buffer
|
||||
p, err := PlanInstall(t.Context(), InstallOptions{StartDir: app, Arg: "acme.shop", Yes: true, Registry: reg, Out: &out})
|
||||
if err != nil || planSteps(p) != "acme.shop@v0.1.0" || !strings.Contains(out.String(), "cannot be read") {
|
||||
t.Errorf("plan: %v, %v\n%s", p, err, out.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user