当前位置: 首页>>代码示例>>Golang>>正文


Golang timeutil.TimeEq函数代码示例

本文整理汇总了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))
}
开发者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


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