lib/model: Run more tests in tmp dir (#5527)

This commit is contained in:
Simon Frei
2019-02-12 16:04:04 +01:00
committed by Jakob Borg
parent 4299af1c63
commit 5fd2cab102
4 changed files with 187 additions and 177 deletions

View File

@@ -7,6 +7,7 @@
package model
import (
"os"
"testing"
"github.com/syncthing/syncthing/lib/fs"
@@ -15,18 +16,17 @@ import (
// Test creating temporary file inside read-only directory
func TestReadOnlyDir(t *testing.T) {
testOs := &fatalOs{t}
// Create a read only directory, clean it up afterwards.
testOs.Mkdir("testdata/read_only_dir", 0555)
defer func() {
testOs.Chmod("testdata/read_only_dir", 0755)
testOs.RemoveAll("testdata/read_only_dir")
}()
tmpDir := createTmpDir()
defer os.RemoveAll(tmpDir)
if err := os.Chmod(tmpDir, 0555); err != nil {
t.Fatal(err)
}
defer os.Chmod(tmpDir, 0755)
s := sharedPullerState{
fs: fs.NewFilesystem(fs.FilesystemTypeBasic, "testdata"),
tempName: "read_only_dir/.temp_name",
fs: fs.NewFilesystem(fs.FilesystemTypeBasic, tmpDir),
tempName: ".temp_name",
mut: sync.NewRWMutex(),
}