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
62bda89c
Commit
62bda89c
authored
Mar 06, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MemFSTest.ModifyExistingFile_InRoot
parent
3a2b0a6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
1 deletion
+52
-1
samples/memfs/memfs_test.go
samples/memfs/memfs_test.go
+52
-1
No files found.
samples/memfs/memfs_test.go
View file @
62bda89c
...
...
@@ -414,7 +414,58 @@ func (t *MemFSTest) CreateNewFile_InSubDir() {
}
func
(
t
*
MemFSTest
)
ModifyExistingFile_InRoot
()
{
AssertTrue
(
false
,
"TODO"
)
var
err
error
var
n
int
var
fi
os
.
FileInfo
var
stat
*
syscall
.
Stat_t
// Write a file.
fileName
:=
path
.
Join
(
t
.
mfs
.
Dir
(),
"foo"
)
createTime
:=
t
.
clock
.
Now
()
err
=
ioutil
.
WriteFile
(
fileName
,
[]
byte
(
"Jello, world!"
),
0600
)
AssertEq
(
nil
,
err
)
// Simulate time advancing.
t
.
clock
.
AdvanceTime
(
time
.
Second
)
// Open the file and modify it.
f
,
err
:=
os
.
OpenFile
(
fileName
,
os
.
O_WRONLY
,
0400
)
t
.
toClose
=
append
(
t
.
toClose
,
f
)
AssertEq
(
nil
,
err
)
modifyTime
:=
t
.
clock
.
Now
()
n
,
err
=
f
.
WriteAt
([]
byte
(
"H"
),
0
)
AssertEq
(
nil
,
err
)
AssertEq
(
1
,
n
)
// Simulate time advancing.
t
.
clock
.
AdvanceTime
(
time
.
Second
)
// Stat the file.
fi
,
err
=
os
.
Stat
(
fileName
)
stat
=
fi
.
Sys
()
.
(
*
syscall
.
Stat_t
)
AssertEq
(
nil
,
err
)
ExpectEq
(
"foo"
,
fi
.
Name
())
ExpectEq
(
len
(
"Hello, world!"
),
fi
.
Size
())
ExpectEq
(
0600
,
fi
.
Mode
())
ExpectEq
(
0
,
fi
.
ModTime
()
.
Sub
(
modifyTime
))
ExpectFalse
(
fi
.
IsDir
())
ExpectNe
(
0
,
stat
.
Ino
)
ExpectEq
(
1
,
stat
.
Nlink
)
ExpectEq
(
currentUid
(),
stat
.
Uid
)
ExpectEq
(
currentGid
(),
stat
.
Gid
)
ExpectEq
(
len
(
"Hello, world!"
),
stat
.
Size
)
ExpectEq
(
0
,
timespecToTime
(
stat
.
Atimespec
)
.
Sub
(
modifyTime
))
ExpectEq
(
0
,
timespecToTime
(
stat
.
Mtimespec
)
.
Sub
(
modifyTime
))
ExpectEq
(
0
,
timespecToTime
(
stat
.
Ctimespec
)
.
Sub
(
createTime
))
// Read the file back.
slice
,
err
:=
ioutil
.
ReadFile
(
fileName
)
AssertEq
(
nil
,
err
)
ExpectEq
(
"Hello, world!"
,
string
(
slice
))
}
func
(
t
*
MemFSTest
)
ModifyExistingFile_InSubDir
()
{
...
...
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