forked from mirror/afero
Support O_TRUNC flag to MemMapFs.OpenFile
To truncate an existing file when opening.
This commit is contained in:
parent
7441922445
commit
582dcbe54c
11
fs_test.go
11
fs_test.go
|
@ -100,6 +100,17 @@ func TestOpenFile(t *testing.T) {
|
|||
t.Errorf("%v: appending, expected '%v', got: '%v'", fs.Name(), expectedContents, string(contents))
|
||||
}
|
||||
f.Close()
|
||||
|
||||
f, err = fs.OpenFile(path, os.O_RDWR|os.O_TRUNC, 0600)
|
||||
if err != nil {
|
||||
t.Error(fs.Name(), "OpenFile (O_TRUNC) failed:", err)
|
||||
continue
|
||||
}
|
||||
contents, _ = ioutil.ReadAll(f)
|
||||
if string(contents) != "" {
|
||||
t.Errorf("%v: expected truncated file, got: '%v'", fs.Name(), string(contents))
|
||||
}
|
||||
f.Close()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue