diff --git a/cmd/restic/integration_helpers_test.go b/cmd/restic/integration_helpers_test.go index 857096c58..734d974c1 100644 --- a/cmd/restic/integration_helpers_test.go +++ b/cmd/restic/integration_helpers_test.go @@ -216,3 +216,13 @@ func withTestEnvironment(t testing.TB, f func(*testEnvironment, GlobalOptions)) RemoveAll(t, tempdir) } + +// removeFile resets the read-only flag and then deletes the file. +func removeFile(fn string) error { + err := os.Chmod(fn, 0666) + if err != nil { + return err + } + + return os.Remove(fn) +} diff --git a/cmd/restic/integration_test.go b/cmd/restic/integration_test.go index baf12fe02..263f6cd16 100644 --- a/cmd/restic/integration_test.go +++ b/cmd/restic/integration_test.go @@ -726,7 +726,7 @@ func TestOptimizeRemoveUnusedBlobs(t *testing.T) { SetupTarTestFixture(t, env.base, test.testFilename) for id := range test.snapshots { - OK(t, os.Remove(filepath.Join(env.repo, "snapshots", id.String()))) + OK(t, removeFile(filepath.Join(env.repo, "snapshots", id.String()))) } cmdOptimize(t, global)