vfs: factor Open logic from Dir.Create into vfs.OpenFile

This commit is contained in:
Nick Craig-Wood 2017-11-06 12:22:45 +00:00
parent 46947b3b9b
commit 3fb1e96988
6 changed files with 39 additions and 34 deletions

View file

@ -278,10 +278,13 @@ func TestDirCreate(t *testing.T) {
defer r.Finalise()
vfs, dir, _ := dirCreate(t, r)
file, fd, err := dir.Create("potato")
file, err := dir.Create("potato")
require.NoError(t, err)
assert.Equal(t, int64(0), file.Size())
fd, err := file.Open(os.O_WRONLY)
require.NoError(t, err)
// FIXME Note that this fails with the current implementation
// until the file has been opened.
@ -300,7 +303,7 @@ func TestDirCreate(t *testing.T) {
assert.Equal(t, int64(5), file2.Size())
vfs.Opt.ReadOnly = true
_, _, err = dir.Create("sausage")
_, err = dir.Create("sausage")
assert.Equal(t, EROFS, err)
}