From 1f9aea9905307c4f082e1e7528ed40fd0e943038 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 8 Nov 2015 22:41:45 +0100 Subject: [PATCH] fix test on windows, reset read-only flag --- cmd/restic/integration_helpers_test.go | 10 ++++++++++ cmd/restic/integration_test.go | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) 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)