Verify vendored recovery after launcher cleanup
This commit is contained in:
@@ -52,18 +52,29 @@ func TestVendoredAPIOnlyPublicationRecovery(t *testing.T) {
|
||||
if err := os.WriteFile(filepath.Join(remote, "hooks", "pre-receive"), []byte("#!/bin/sh\nexit 1\n"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var out, diagnostics bytes.Buffer
|
||||
if status := run(t.Context(), []string{"publish", "--repo", repo, "v1.2.3"}, &out, &diagnostics); status != 1 {
|
||||
t.Fatalf("publication status=%d: %s", status, &diagnostics)
|
||||
launcherStore := t.TempDir()
|
||||
launcherArgs, err := gotool.RecoveryTool(t.Context(), repo, launcherStore)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
command := outputLineValue(diagnostics.String(), "recovery command: ")
|
||||
launcher := exec.Command(goBinary, append(launcherArgs, "publish", "--repo", repo, "v1.2.3")...)
|
||||
launcher.Dir = t.TempDir()
|
||||
publicationOutput, err := launcher.CombinedOutput()
|
||||
var exitError *exec.ExitError
|
||||
if !errors.As(err, &exitError) || exitError.ExitCode() != 1 {
|
||||
t.Fatalf("vendored publication: %v: %s", err, publicationOutput)
|
||||
}
|
||||
// The later handoff owns different launch metadata from the original driver.
|
||||
if err := os.RemoveAll(launcherStore); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
command := outputLineValue(string(publicationOutput), "recovery command: ")
|
||||
if command == "" {
|
||||
t.Fatalf("no handoff: %s", &diagnostics)
|
||||
t.Fatalf("no handoff: %s", publicationOutput)
|
||||
}
|
||||
recovery := exec.Command("sh", "-c", command)
|
||||
recovery.Dir = t.TempDir()
|
||||
recovered, err := recovery.CombinedOutput()
|
||||
var exitError *exec.ExitError
|
||||
if !errors.As(err, &exitError) || exitError.ExitCode() != 1 || !strings.Contains(string(recovered), "module=example.com/cli-candidate tag=v1.2.3 state=not_published") {
|
||||
t.Fatalf("vendored recovery: %v: %s", err, recovered)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user