Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
jacobsa-fuse
Commits
b814416b
Commit
b814416b
authored
Mar 06, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PosixTest.AppendMode
parent
b8ea6298
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
samples/memfs/posix_test.go
samples/memfs/posix_test.go
+46
-0
No files found.
samples/memfs/posix_test.go
View file @
b814416b
...
...
@@ -218,6 +218,52 @@ func (t *PosixTest) WriteAtDoesntChangeOffset_AppendMode() {
ExpectEq
(
4
,
offset
)
}
func
(
t
*
PosixTest
)
AppendMode
()
{
var
err
error
var
n
int
var
off
int64
buf
:=
make
([]
byte
,
1024
)
// Create a file with some contents.
fileName
:=
path
.
Join
(
t
.
dir
,
"foo"
)
err
=
ioutil
.
WriteFile
(
fileName
,
[]
byte
(
"Jello, "
),
0600
)
AssertEq
(
nil
,
err
)
// Open the file in append mode.
f
,
err
:=
os
.
OpenFile
(
fileName
,
os
.
O_RDWR
|
os
.
O_APPEND
,
0600
)
t
.
toClose
=
append
(
t
.
toClose
,
f
)
AssertEq
(
nil
,
err
)
// Seek to somewhere silly and then write.
off
,
err
=
f
.
Seek
(
2
,
0
)
AssertEq
(
nil
,
err
)
AssertEq
(
2
,
off
)
n
,
err
=
f
.
Write
([]
byte
(
"world!"
))
AssertEq
(
nil
,
err
)
AssertEq
(
6
,
n
)
// The offset should have been updated to point at the end of the file.
off
,
err
=
getFileOffset
(
f
)
AssertEq
(
nil
,
err
)
ExpectEq
(
13
,
off
)
// A random write should still work, without updating the offset.
n
,
err
=
f
.
WriteAt
([]
byte
(
"H"
),
0
)
AssertEq
(
nil
,
err
)
AssertEq
(
1
,
n
)
off
,
err
=
getFileOffset
(
f
)
AssertEq
(
nil
,
err
)
ExpectEq
(
13
,
off
)
// Read back the contents of the file, which should be correct even though we
// seeked to a silly place before writing the world part.
n
,
err
=
f
.
ReadAt
(
buf
,
0
)
AssertEq
(
io
.
EOF
,
err
)
ExpectEq
(
"Hello, world!"
,
string
(
buf
[
:
n
]))
}
func
(
t
*
PosixTest
)
ReadsPastEndOfFile
()
{
var
err
error
var
n
int
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment