本文整理汇总了Golang中github.com/jacobsa/timeutil.TimeEq函数的典型用法代码示例。如果您正苦于以下问题:Golang TimeEq函数的具体用法?Golang TimeEq怎么用?Golang TimeEq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TimeEq函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: StatStat
func (t *AttributeCachingTest) StatStat() {
fooBefore, dirBefore, barBefore := t.statAll()
fooAfter, dirAfter, barAfter := t.statAll()
// Make sure everything matches.
ExpectThat(fooAfter.ModTime(), timeutil.TimeEq(fooBefore.ModTime()))
ExpectThat(dirAfter.ModTime(), timeutil.TimeEq(dirBefore.ModTime()))
ExpectThat(barAfter.ModTime(), timeutil.TimeEq(barBefore.ModTime()))
ExpectEq(getInodeID(fooBefore), getInodeID(fooAfter))
ExpectEq(getInodeID(dirBefore), getInodeID(dirAfter))
ExpectEq(getInodeID(barBefore), getInodeID(barAfter))
}
示例2: StatMtimeStat
func (t *EntryCachingTest) StatMtimeStat() {
newMtime := t.initialMtime.Add(time.Second)
t.statAll()
t.fs.SetMtime(newMtime)
fooAfter, dirAfter, barAfter := t.statAll()
// We should see the new mtimes, because the attributes should not have been
// cached.
ExpectThat(fooAfter.ModTime(), timeutil.TimeEq(newMtime))
ExpectThat(dirAfter.ModTime(), timeutil.TimeEq(newMtime))
ExpectThat(barAfter.ModTime(), timeutil.TimeEq(newMtime))
}
示例3: InitialAttributes
func (t *FileTest) InitialAttributes() {
attrs, err := t.in.Attributes(t.ctx)
AssertEq(nil, err)
ExpectEq(len(t.initialContents), attrs.Size)
ExpectEq(1, attrs.Nlink)
ExpectEq(uid, attrs.Uid)
ExpectEq(gid, attrs.Gid)
ExpectEq(fileMode, attrs.Mode)
ExpectThat(attrs.Atime, timeutil.TimeEq(t.backingObj.Updated))
ExpectThat(attrs.Ctime, timeutil.TimeEq(t.backingObj.Updated))
ExpectThat(attrs.Mtime, timeutil.TimeEq(t.backingObj.Updated))
}
示例4: SetMtime
func (t *TempFileTest) SetMtime() {
mtime := time.Date(2015, 4, 5, 2, 15, 0, 0, time.Local)
AssertThat(mtime, Not(timeutil.TimeEq(t.clock.Now())))
// Set.
t.tf.SetMtime(mtime)
// Check.
sr, err := t.tf.Stat()
AssertEq(nil, err)
ExpectThat(sr.Mtime, Pointee(timeutil.TimeEq(mtime)))
}
示例5: WrappedSucceeds
func (t *StatObjectTest) WrappedSucceeds() {
const name = "taco"
// LookUp
ExpectCall(t.cache, "LookUp")(Any(), Any()).
WillOnce(Return(false, nil))
// Wrapped
obj := &gcs.Object{
Name: name,
}
ExpectCall(t.wrapped, "StatObject")(Any(), Any()).
WillOnce(Return(obj, nil))
// Insert
ExpectCall(t.cache, "Insert")(obj, timeutil.TimeEq(t.clock.Now().Add(ttl)))
// Call
req := &gcs.StatObjectRequest{
Name: name,
}
o, err := t.bucket.StatObject(nil, req)
AssertEq(nil, err)
ExpectEq(obj, o)
}
示例6: StatMtimeStat_ViaPath
func (t *AttributeCachingTest) StatMtimeStat_ViaPath() {
newMtime := t.initialMtime.Add(time.Second)
t.statAll()
t.fs.SetMtime(newMtime)
fooAfter, dirAfter, barAfter := t.statAll()
// Since we don't have entry caching enabled, the call above had to look up
// the entry again. With the lookup we returned new attributes, so it's
// possible that the mtime will be fresh. On Linux it appears to be, and on
// OS X it appears to not be.
m := AnyOf(timeutil.TimeEq(newMtime), timeutil.TimeEq(t.initialMtime))
ExpectThat(fooAfter.ModTime(), m)
ExpectThat(dirAfter.ModTime(), m)
ExpectThat(barAfter.ModTime(), m)
}
示例7: Write
func (t *FileTest) Write() {
var data []byte
var err error
AssertEq("taco", t.initialContents)
// Overwite a byte.
err = t.in.Write(t.ctx, []byte("p"), 0)
AssertEq(nil, err)
// Add some data at the end.
t.clock.AdvanceTime(time.Second)
writeTime := t.clock.Now()
err = t.in.Write(t.ctx, []byte("burrito"), 4)
AssertEq(nil, err)
t.clock.AdvanceTime(time.Second)
// Read back the content.
data, err = t.in.Read(t.ctx, 0, 1024)
AssertEq(nil, err)
ExpectEq("pacoburrito", string(data))
// Check attributes.
attrs, err := t.in.Attributes(t.ctx)
AssertEq(nil, err)
ExpectEq(len("pacoburrito"), attrs.Size)
ExpectThat(attrs.Mtime, timeutil.TimeEq(writeTime))
}
示例8: TruncateUpwardThenSync
func (t *FileTest) TruncateUpwardThenSync() {
var attrs fuseops.InodeAttributes
var err error
AssertEq(4, len(t.initialContents))
// Truncate upward.
err = t.in.Truncate(t.ctx, 6)
AssertEq(nil, err)
t.clock.AdvanceTime(time.Second)
// Sync.
err = t.in.Sync(t.ctx)
AssertEq(nil, err)
// The generation should have advanced.
ExpectLt(t.backingObj.Generation, t.in.SourceGeneration())
// Stat the current object in the bucket.
statReq := &gcs.StatObjectRequest{Name: t.in.Name()}
o, err := t.bucket.StatObject(t.ctx, statReq)
AssertEq(nil, err)
ExpectEq(t.in.SourceGeneration(), o.Generation)
ExpectEq(6, o.Size)
// Check attributes.
attrs, err = t.in.Attributes(t.ctx)
AssertEq(nil, err)
ExpectEq(6, attrs.Size)
ExpectThat(attrs.Mtime, timeutil.TimeEq(o.Updated))
}
示例9: Truncate
func (t *FileTest) Truncate() {
var attrs fuseops.InodeAttributes
var err error
AssertEq("taco", t.initialContents)
// Truncate downward.
t.clock.AdvanceTime(time.Second)
truncateTime := t.clock.Now()
err = t.in.Truncate(t.ctx, 2)
AssertEq(nil, err)
t.clock.AdvanceTime(time.Second)
// Read the contents.
var buf [1024]byte
n, err := t.in.Read(t.ctx, buf[:], 0)
if err == io.EOF {
err = nil
}
AssertEq(nil, err)
ExpectEq("ta", string(buf[:n]))
// Check attributes.
attrs, err = t.in.Attributes(t.ctx)
AssertEq(nil, err)
ExpectEq(len("ta"), attrs.Size)
ExpectThat(attrs.Mtime, timeutil.TimeEq(truncateTime))
}
示例10: SetMtime_ContentClean
func (t *FileTest) SetMtime_ContentClean() {
var err error
var attrs fuseops.InodeAttributes
// Cause the content to be faulted in.
_, err = t.in.Read(t.ctx, make([]byte, 1), 0)
AssertEq(nil, err)
// Set mtime.
mtime := time.Now().UTC().Add(123 * time.Second)
err = t.in.SetMtime(t.ctx, mtime)
AssertEq(nil, err)
// The inode should agree about the new mtime.
attrs, err = t.in.Attributes(t.ctx)
AssertEq(nil, err)
ExpectThat(attrs.Mtime, timeutil.TimeEq(mtime))
// The inode should have added the mtime to the backing object's metadata.
statReq := &gcs.StatObjectRequest{Name: t.in.Name()}
o, err := t.bucket.StatObject(t.ctx, statReq)
AssertEq(nil, err)
ExpectEq(
mtime.UTC().Format(time.RFC3339Nano),
o.Metadata["gcsfuse_mtime"])
}
示例11: WrappedSaysNotFound
func (t *StatObjectTest) WrappedSaysNotFound() {
const name = "taco"
// LookUp
ExpectCall(t.cache, "LookUp")(Any(), Any()).
WillOnce(Return(false, nil))
// Wrapped
ExpectCall(t.wrapped, "StatObject")(Any(), Any()).
WillOnce(Return(nil, &gcs.NotFoundError{Err: errors.New("burrito")}))
// AddNegativeEntry
ExpectCall(t.cache, "AddNegativeEntry")(
name,
timeutil.TimeEq(t.clock.Now().Add(ttl)))
// Call
req := &gcs.StatObjectRequest{
Name: name,
}
_, err := t.bucket.StatObject(nil, req)
ExpectThat(err, HasSameTypeAs(&gcs.NotFoundError{}))
ExpectThat(err, Error(HasSubstr("burrito")))
}
示例12: SetMtime_ContentDirty
func (t *FileTest) SetMtime_ContentDirty() {
var err error
var attrs fuseops.InodeAttributes
// Dirty the content.
err = t.in.Write(t.ctx, []byte("a"), 0)
AssertEq(nil, err)
// Set mtime.
mtime := time.Now().UTC().Add(123 * time.Second)
err = t.in.SetMtime(t.ctx, mtime)
AssertEq(nil, err)
// The inode should agree about the new mtime.
attrs, err = t.in.Attributes(t.ctx)
AssertEq(nil, err)
ExpectThat(attrs.Mtime, timeutil.TimeEq(mtime))
// Sync.
err = t.in.Sync(t.ctx)
AssertEq(nil, err)
// Now the object in the bucket should have the appropriate mtime.
statReq := &gcs.StatObjectRequest{Name: t.in.Name()}
o, err := t.bucket.StatObject(t.ctx, statReq)
AssertEq(nil, err)
ExpectEq(
mtime.UTC().Format(time.RFC3339Nano),
o.Metadata["gcsfuse_mtime"])
}
示例13: WriteAt
func (t *TempFileTest) WriteAt() {
// Call
p := []byte("fo")
n, err := t.tf.WriteAt(p, 1)
ExpectEq(2, n)
ExpectEq(nil, err)
// Check Stat.
sr, err := t.tf.Stat()
AssertEq(nil, err)
ExpectEq(initialContentSize, sr.Size)
ExpectEq(1, sr.DirtyThreshold)
ExpectThat(sr.Mtime, Pointee(timeutil.TimeEq(t.clock.Now())))
// Read back.
expected := []byte(initialContent)
expected[1] = 'f'
expected[2] = 'o'
actual, err := readAll(&t.tf)
AssertEq(nil, err)
ExpectEq(string(expected), string(actual))
}
示例14: StatRenumberMtimeStat
func (t *NoCachingTest) StatRenumberMtimeStat() {
newMtime := t.initialMtime.Add(time.Second)
t.statAll()
t.fs.RenumberInodes()
t.fs.SetMtime(newMtime)
fooAfter, dirAfter, barAfter := t.statAll()
// We should see the new inode IDs and mtimes, because nothing should have
// been cached.
ExpectEq(t.fs.FooID(), getInodeID(fooAfter))
ExpectEq(t.fs.DirID(), getInodeID(dirAfter))
ExpectEq(t.fs.BarID(), getInodeID(barAfter))
ExpectThat(fooAfter.ModTime(), timeutil.TimeEq(newMtime))
ExpectThat(dirAfter.ModTime(), timeutil.TimeEq(newMtime))
ExpectThat(barAfter.ModTime(), timeutil.TimeEq(newMtime))
}
示例15: StatRenumberMtimeStat_ViaPath
func (t *AttributeCachingTest) StatRenumberMtimeStat_ViaPath() {
newMtime := t.initialMtime.Add(time.Second)
t.statAll()
t.fs.RenumberInodes()
t.fs.SetMtime(newMtime)
fooAfter, dirAfter, barAfter := t.statAll()
// We should see new everything, because this is the first time the new
// inodes have been encountered. Entries for the old ones should not have
// been cached, because we have entry caching disabled.
ExpectEq(t.fs.FooID(), getInodeID(fooAfter))
ExpectEq(t.fs.DirID(), getInodeID(dirAfter))
ExpectEq(t.fs.BarID(), getInodeID(barAfter))
ExpectThat(fooAfter.ModTime(), timeutil.TimeEq(newMtime))
ExpectThat(dirAfter.ModTime(), timeutil.TimeEq(newMtime))
ExpectThat(barAfter.ModTime(), timeutil.TimeEq(newMtime))
}