• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang timeutil.TimeEq函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/jacobsa/timeutil.TimeEq函数的典型用法代码示例。如果您正苦于以下问题:Golang TimeEq函数的具体用法?Golang TimeEq怎么用?Golang TimeEq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了TimeEq函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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))
}
开发者ID:andrewgaul,项目名称:fuse,代码行数:13,代码来源:caching_fs_test.go


示例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))
}
开发者ID:andrewgaul,项目名称:fuse,代码行数:13,代码来源:caching_fs_test.go


示例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))
}
开发者ID:zfo,项目名称:gcsfuse,代码行数:13,代码来源:file_test.go


示例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)))
}
开发者ID:horzadome,项目名称:gcsfuse,代码行数:13,代码来源:temp_file_test.go


示例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)
}
开发者ID:okdave,项目名称:gcloud,代码行数:27,代码来源:fast_stat_bucket_test.go


示例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)
}
开发者ID:andrewgaul,项目名称:fuse,代码行数:16,代码来源:caching_fs_test.go


示例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))
}
开发者ID:mbookman,项目名称:gcsfuse,代码行数:31,代码来源:file_test.go


示例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))
}
开发者ID:mbookman,项目名称:gcsfuse,代码行数:34,代码来源:file_test.go


示例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))
}
开发者ID:zfo,项目名称:gcsfuse,代码行数:33,代码来源:file_test.go


示例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"])
}
开发者ID:zfo,项目名称:gcsfuse,代码行数:29,代码来源:file_test.go


示例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")))
}
开发者ID:okdave,项目名称:gcloud,代码行数:25,代码来源:fast_stat_bucket_test.go


示例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"])
}
开发者ID:zfo,项目名称:gcsfuse,代码行数:33,代码来源:file_test.go


示例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))
}
开发者ID:horzadome,项目名称:gcsfuse,代码行数:25,代码来源:temp_file_test.go


示例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))
}
开发者ID:andrewgaul,项目名称:fuse,代码行数:18,代码来源:caching_fs_test.go


示例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))
}
开发者ID:andrewgaul,项目名称:fuse,代码行数:19,代码来源:caching_fs_test.go


示例16: StatDir

func (t *BasicsTest) StatDir() {
	fi, err := os.Stat(path.Join(t.Dir, "dir"))
	AssertEq(nil, err)

	ExpectEq("dir", fi.Name())
	ExpectEq(os.ModeDir|0777, fi.Mode())
	ExpectThat(fi.ModTime(), timeutil.TimeEq(t.initialMtime))
	ExpectTrue(fi.IsDir())
	ExpectEq(t.fs.DirID(), getInodeID(fi))
	ExpectEq(1, fi.Sys().(*syscall.Stat_t).Nlink)
}
开发者ID:andrewgaul,项目名称:fuse,代码行数:11,代码来源:caching_fs_test.go


示例17: StatBar

func (t *BasicsTest) StatBar() {
	fi, err := os.Stat(path.Join(t.Dir, "dir/bar"))
	AssertEq(nil, err)

	ExpectEq("bar", fi.Name())
	ExpectEq(cachingfs.BarSize, fi.Size())
	ExpectEq(0777, fi.Mode())
	ExpectThat(fi.ModTime(), timeutil.TimeEq(t.initialMtime))
	ExpectFalse(fi.IsDir())
	ExpectEq(t.fs.BarID(), getInodeID(fi))
	ExpectEq(1, fi.Sys().(*syscall.Stat_t).Nlink)
}
开发者ID:andrewgaul,项目名称:fuse,代码行数:12,代码来源:caching_fs_test.go


示例18: StatMtimeStat_ViaFileDescriptor

func (t *AttributeCachingTest) StatMtimeStat_ViaFileDescriptor() {
	newMtime := t.initialMtime.Add(time.Second)

	// Open everything, fixing a particular inode number for each.
	foo, dir, bar := t.openFiles()
	defer func() {
		foo.Close()
		dir.Close()
		bar.Close()
	}()

	fooBefore, dirBefore, barBefore := t.statFiles(foo, dir, bar)
	t.fs.SetMtime(newMtime)
	fooAfter, dirAfter, barAfter := t.statFiles(foo, dir, bar)

	// We should still see the old cached mtime.
	ExpectThat(fooAfter.ModTime(), timeutil.TimeEq(fooBefore.ModTime()))
	ExpectThat(dirAfter.ModTime(), timeutil.TimeEq(dirBefore.ModTime()))
	ExpectThat(barAfter.ModTime(), timeutil.TimeEq(barBefore.ModTime()))

	// After waiting for the attribute cache to expire, we should see the fresh
	// mtime.
	time.Sleep(2 * t.getattrTimeout)
	fooAfter, dirAfter, barAfter = t.statFiles(foo, dir, bar)

	ExpectThat(fooAfter.ModTime(), timeutil.TimeEq(newMtime))
	ExpectThat(dirAfter.ModTime(), timeutil.TimeEq(newMtime))
	ExpectThat(barAfter.ModTime(), timeutil.TimeEq(newMtime))
}
开发者ID:andrewgaul,项目名称:fuse,代码行数:29,代码来源:caching_fs_test.go


示例19: NonEmptyListing

func (t *ListObjectsTest) NonEmptyListing() {
	// Wrapped
	o0 := &gcs.Object{Name: "taco"}
	o1 := &gcs.Object{Name: "burrito"}

	expected := &gcs.Listing{
		Objects: []*gcs.Object{o0, o1},
	}

	ExpectCall(t.wrapped, "ListObjects")(Any(), Any()).
		WillOnce(Return(expected, nil))

	// Insert
	ExpectCall(t.cache, "Insert")(o0, timeutil.TimeEq(t.clock.Now().Add(ttl)))
	ExpectCall(t.cache, "Insert")(o1, timeutil.TimeEq(t.clock.Now().Add(ttl)))

	// Call
	listing, err := t.bucket.ListObjects(nil, &gcs.ListObjectsRequest{})

	AssertEq(nil, err)
	ExpectEq(expected, listing)
}
开发者ID:okdave,项目名称:gcloud,代码行数:22,代码来源:fast_stat_bucket_test.go


示例20: Stat_LeaseSucceeds

func (t *DirtyTest) Stat_LeaseSucceeds() {
	// Lease
	ExpectCall(t.rwl, "Size")().
		WillOnce(Return(17, nil))

	// Call
	sr, err := t.mc.Stat()
	AssertEq(nil, err)

	// Check the initial state.
	ExpectEq(17, sr.Size)
	ExpectEq(initialContentSize, sr.DirtyThreshold)
	ExpectThat(sr.Mtime, Pointee(timeutil.TimeEq(t.setUpTime)))
}
开发者ID:mbookman,项目名称:gcsfuse,代码行数:14,代码来源:content_test.go



注:本文中的github.com/jacobsa/timeutil.TimeEq函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang db.GetByQ函数代码示例发布时间:2022-05-23
下一篇:
Golang syncutil.NewInvariantMutex函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap