From 361fbbf58fc15f9604cf2922e425a129e50ede3b Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Thu, 29 Aug 2024 16:33:18 +0200 Subject: [PATCH] Add temporary files repositories in integration tests This is intended to catch problems with temporary files stored in the backend, even if the responsible component forgets to test for those. --- cmd/restic/cmd_init_integration_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/restic/cmd_init_integration_test.go b/cmd/restic/cmd_init_integration_test.go index 9b5eed6e0..4795d5510 100644 --- a/cmd/restic/cmd_init_integration_test.go +++ b/cmd/restic/cmd_init_integration_test.go @@ -2,6 +2,8 @@ package main import ( "context" + "os" + "path/filepath" "testing" "github.com/restic/restic/internal/repository" @@ -16,6 +18,11 @@ func testRunInit(t testing.TB, opts GlobalOptions) { rtest.OK(t, runInit(context.TODO(), InitOptions{}, opts, nil)) t.Logf("repository initialized at %v", opts.Repo) + + // create temporary junk files to verify that restic does not trip over them + for _, path := range []string{"index", "snapshots", "keys", "locks", filepath.Join("data", "00")} { + rtest.OK(t, os.WriteFile(filepath.Join(opts.Repo, path, "tmp12345"), []byte("junk file"), 0o600)) + } } func TestInitCopyChunkerParams(t *testing.T) {