lib/model: Improve filesystem operations during tests (fixes #5422)
* lib/fs, lib/model: Improve filesystem operations during tests (fixes #5422) Introduces MustFilesystem that panics on errors and should be used for operations during testing which must never fail. Create temporary directories outside of testdata. * don't do a filesystem, just a wrapper around os for testing * fix copyright
This commit is contained in:
committed by
Audrius Butkevicius
parent
24ffd8be99
commit
0b03b6a9ec
@@ -7,7 +7,6 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/fs"
|
||||
@@ -16,11 +15,13 @@ 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.
|
||||
os.Mkdir("testdata/read_only_dir", 0555)
|
||||
testOs.Mkdir("testdata/read_only_dir", 0555)
|
||||
defer func() {
|
||||
os.Chmod("testdata/read_only_dir", 0755)
|
||||
os.RemoveAll("testdata/read_only_dir")
|
||||
testOs.Chmod("testdata/read_only_dir", 0755)
|
||||
testOs.RemoveAll("testdata/read_only_dir")
|
||||
}()
|
||||
|
||||
s := sharedPullerState{
|
||||
|
||||
Reference in New Issue
Block a user