Upstream spf13/afero state of the touched files before ac8fa0258e
This commit is contained in:
1 parent
b778e8e78b
commit
d43dc733dc
2 files changed
+1
-32
No files matched your search
@@ -135,35 +135,6 @@ func TestOpenFileExcl(t *testing.T) {
|
||||
checkPathError(t, err, "Open")
|
||||
}
|
||||
|
||||
// Ensure os.O_EXCL only rejects an existing file when os.O_CREATE is also
|
||||
// requested. Per POSIX, O_EXCL is meaningful only in combination with
|
||||
// O_CREATE, so opening an existing file with O_RDWR|O_EXCL must succeed.
|
||||
func TestOpenFileExclWithoutCreate(t *testing.T) {
|
||||
const fileName = "/myExclNoCreate"
|
||||
const fileMode = os.FileMode(0o644)
|
||||
|
||||
fs := NewMemMapFs()
|
||||
|
||||
// Create the file up front.
|
||||
f, err := fs.OpenFile(fileName, os.O_CREATE|os.O_RDWR|os.O_EXCL, fileMode)
|
||||
if err != nil {
|
||||
t.Fatalf("initial create failed: %s", err)
|
||||
}
|
||||
f.Close()
|
||||
|
||||
// Reopening with O_EXCL but without O_CREATE must succeed.
|
||||
f, err = fs.OpenFile(fileName, os.O_RDWR|os.O_EXCL, fileMode)
|
||||
if err != nil {
|
||||
t.Fatalf("OpenFile(O_RDWR|O_EXCL) on existing file should succeed, got: %s", err)
|
||||
}
|
||||
f.Close()
|
||||
|
||||
// O_CREATE|O_EXCL on an existing file must still fail.
|
||||
if _, err := fs.OpenFile(fileName, os.O_CREATE|os.O_RDWR|os.O_EXCL, fileMode); err == nil {
|
||||
t.Fatalf("OpenFile(O_CREATE|O_EXCL) on existing file should fail, but it didn't")
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure Permissions are set on OpenFile/Mkdir/MkdirAll
|
||||
func TestPermSet(t *testing.T) {
|
||||
const fileName = "/myFileTest"
|
||||
|
||||
Reference in new issue
Block a user