Skip to content

Commit

Permalink
cache: strip monotonic clock reading for comparisons (#7)
Browse files Browse the repository at this point in the history
Comparing Time values with require.Equal fails because
one of the arguments has a monotonic clock reading and
because require.Equal doesn't use time.Equal for
comparison [1].

[1] stretchr/testify#502
  • Loading branch information
tetsuok authored and jmmv committed Jan 5, 2020
1 parent 20643a4 commit 0dc3301
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/cache/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ func (s *MetadataCacheSuite) TestPutNewOrUpdate() {
func (s *MetadataCacheSuite) TestPutFileInfoAndGet() {
inode, err := s.cache.PutNewWithType("/path", 0)
s.Require().NoError(err)

fileInfo := newFileInfo("/path", 123, 0, time.Now())
// Strip monotonic clock reading for comparisons with require.Equal.
// See https://github.com/stretchr/testify/issues/502 for details.
fileInfo := newFileInfo("/path", 123, 0, time.Now().Round(0))
s.Require().NoError(s.cache.PutFileInfo(inode, fileInfo))

row := s.checkedGetFullEntry("/path", "file")
Expand Down

0 comments on commit 0dc3301

Please sign in to comment.