From 6619ac9620e3d9b42ad665297484b2f79602e7a7 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 15 Nov 2026 19:14:35 +0100 Subject: [PATCH] prune: drop test already covered by unit test --- changelog/unreleased/issue-22092 | 1 + cmd/restic/cmd_prune_integration_test.go | 51 ------------------------ 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/changelog/unreleased/issue-22092 b/changelog/unreleased/issue-22092 index ae6a0d544..bd8358663 100644 --- a/changelog/unreleased/issue-22092 +++ b/changelog/unreleased/issue-22092 @@ -6,3 +6,4 @@ versions of `repair snapshots` could fail with `error decoding tree: expected `prune`, `check` and `restore` to process the affected snapshots. https://github.com/restic/restic/issues/22092 +https://github.com/restic/restic/pull/22117 diff --git a/cmd/restic/cmd_prune_integration_test.go b/cmd/restic/cmd_prune_integration_test.go index 837648536..200d36f06 100644 --- a/cmd/restic/cmd_prune_integration_test.go +++ b/cmd/restic/cmd_prune_integration_test.go @@ -3,16 +3,12 @@ package main import ( "context" "encoding/json" - "os" "path/filepath" "testing" - "time" "github.com/restic/restic/internal/backend" - "github.com/restic/restic/internal/data" "github.com/restic/restic/internal/global" "github.com/restic/restic/internal/repository" - "github.com/restic/restic/internal/restic" rtest "github.com/restic/restic/internal/test" ) @@ -127,53 +123,6 @@ func testPrune(t *testing.T, pruneOpts PruneOptions, checkOpts CheckOptions) { var pruneDefaultOptions = PruneOptions{MaxUnused: "5%"} -func TestPruneWithLegacyEmptyTree(t *testing.T) { - env, cleanup := withTestEnvironment(t) - defer cleanup() - testRunInit(t, env.gopts) - - ctx := context.Background() - var repo *repository.Repository - rtest.OK(t, withTermStatus(t, env.gopts, func(ctx context.Context, gopts global.Options) error { - var err error - repo, err = global.OpenRepository(ctx, gopts, restic.NewNoopPrinter()) - return err - })) - defer func() { rtest.OK(t, repo.Close()) }() - contents := []byte("file next to a repaired empty directory") - mtime := time.Unix(1700000000, 0) - var treeID restic.ID - rtest.OK(t, repo.WithBlobUploader(ctx, func(ctx context.Context, uploader restic.BlobSaverWithAsync) error { - // repair snapshots in restic 0.18.1 saved missing subtrees as {"nodes":null}. - emptyID, _, _, err := uploader.SaveBlob(ctx, restic.TreeBlob, []byte("{\"nodes\":null}\n"), restic.ID{}, false) - if err != nil { - return err - } - fileID, _, _, err := uploader.SaveBlob(ctx, restic.DataBlob, contents, restic.ID{}, false) - if err != nil { - return err - } - treeID = data.TestSaveNodes(t, ctx, uploader, []*data.Node{ - {Name: "empty", Type: data.NodeTypeDir, Mode: 0755, ModTime: mtime, AccessTime: mtime, Subtree: &emptyID}, - {Name: "keep.txt", Type: data.NodeTypeFile, Mode: 0644, ModTime: mtime, AccessTime: mtime, Size: uint64(len(contents)), Content: restic.IDs{fileID}}, - }) - return nil - })) - _, err := data.SaveSnapshot(ctx, repo, &data.Snapshot{Tree: &treeID, Time: mtime, Paths: []string{"/test"}}) - rtest.OK(t, err) - - testRunPrune(t, env.gopts, pruneDefaultOptions) - testRunCheck(t, env.gopts) - target := t.TempDir() - testRunRestore(t, env.gopts, target, "latest") - got, err := os.ReadFile(filepath.Join(target, "keep.txt")) - rtest.OK(t, err) - rtest.Equals(t, contents, got) - entries, err := os.ReadDir(filepath.Join(target, "empty")) - rtest.OK(t, err) - rtest.Equals(t, 0, len(entries)) -} - func TestPruneWithDamagedRepository(t *testing.T) { env, cleanup := withTestEnvironment(t) defer cleanup()