fix test on windows, reset read-only flag

This commit is contained in:
Alexander Neumann 2015-11-08 22:41:45 +01:00
parent 742d69bf4d
commit 1f9aea9905
2 changed files with 11 additions and 1 deletions

View File

@ -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)
}

View File

@ -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)