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.
This commit is contained in:
Michael Eischer 2024-08-29 16:33:18 +02:00
parent 8eff4e0e5c
commit d19f706d50

View file

@ -2,6 +2,8 @@ package main
import ( import (
"context" "context"
"os"
"path/filepath"
"testing" "testing"
"github.com/restic/restic/internal/repository" "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)) rtest.OK(t, runInit(context.TODO(), InitOptions{}, opts, nil))
t.Logf("repository initialized at %v", opts.Repo) 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) { func TestInitCopyChunkerParams(t *testing.T) {