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
47570943
Commit
47570943
authored
Mar 16, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented MtimeIs.
parent
72b8c3e9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
+34
-4
fusetesting/stat.go
fusetesting/stat.go
+34
-4
No files found.
fusetesting/stat.go
View file @
47570943
...
...
@@ -15,17 +15,47 @@
package
fusetesting
import
(
"fmt"
"os"
"reflect"
"time"
"github.com/jacobsa/oglematchers"
)
// Match
*
os.FileInfo values that specify an mtime equal to the given time. On
// Match os.FileInfo values that specify an mtime equal to the given time. On
// platforms where the Sys() method returns a struct containing an mtime, check
// also that it matches.
func
MtimeIs
(
expected
time
.
Time
)
oglematchers
.
Matcher
func
MtimeIs
(
expected
time
.
Time
)
oglematchers
.
Matcher
{
return
oglematchers
.
NewMatcher
(
func
(
c
interface
{})
error
{
return
mtimeIs
(
c
,
expected
)
},
fmt
.
Sprintf
(
"mtime is %v"
,
expected
))
}
// Match *os.FileInfo values that specify a file birth time equal to the given
func
mtimeIs
(
c
interface
{},
expected
time
.
Time
)
error
{
fi
,
ok
:=
c
.
(
os
.
FileInfo
)
if
!
ok
{
return
fmt
.
Errorf
(
"which is of type %v"
,
reflect
.
TypeOf
(
c
))
}
// Check ModTime().
if
fi
.
ModTime
()
!=
expected
{
d
:=
fi
.
ModTime
()
.
Sub
(
expected
)
return
fmt
.
Errorf
(
"which has mtime %v, off by %v"
,
fi
.
ModTime
(),
d
)
}
// Check Sys().
if
sysMtime
,
ok
:=
extractMtime
(
fi
.
Sys
());
ok
{
if
sysMtime
!=
expected
{
d
:=
sysMtime
.
Sub
(
expected
)
return
fmt
.
Errorf
(
"which has Sys() mtime %v, off by %v"
,
sysMtime
,
d
)
}
}
return
nil
}
// Match os.FileInfo values that specify a file birth time equal to the given
// time. On platforms where there is no birth time available, match all
//
*
os.FileInfo values.
// os.FileInfo values.
func
BirthtimeIs
(
expected
time
.
Time
)
oglematchers
.
Matcher
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