Don't leave read only dir around, fails clean

This commit is contained in:
Jakob Borg 2014-11-20 23:27:49 +01:00
parent 2cd9e7fb55
commit ce948fc512
2 changed files with 7 additions and 4 deletions

View File

@ -17,7 +17,6 @@ package model
import (
"os"
"path/filepath"
"testing"
)
@ -68,13 +67,17 @@ func TestSourceFileBad(t *testing.T) {
// Test creating temporary file inside read-only directory
func TestReadOnlyDir(t *testing.T) {
// Create a read only directory, clean it up afterwards.
os.Mkdir("testdata/read_only_dir", 0555)
defer func() {
os.Chmod("testdata/read_only_dir", 0755)
os.RemoveAll("testdata/read_only_dir")
}()
s := sharedPullerState{
tempName: "testdata/read_only_dir/.temp_name",
}
// Ensure dir is read-only (git doesn't store full permissions)
os.Chmod(filepath.Dir(s.tempName), 0555)
fd, err := s.tempFile()
if err != nil {
t.Fatal(err)