Skip to content

Commit 9d2e900

Browse files
authored
Merge pull request #1765 from AArnott/fix1764
Improve stability of AssertRefLogEntry-based tests
2 parents 7e40e96 + 972f78a commit 9d2e900

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,11 @@ protected static void AssertRefLogEntry(IRepository repo, string canonicalName,
467467
Assert.Equal(@from ?? ObjectId.Zero, reflogEntry.From);
468468

469469
Assert.Equal(committer.Email, reflogEntry.Committer.Email);
470-
Assert.InRange(reflogEntry.Committer.When, before, DateTimeOffset.Now);
470+
471+
// When verifying the timestamp range, give a little more room on the 'before' side.
472+
// Git or file system datetime truncation seems to cause these stamps to jump up to a second earlier
473+
// than we expect. See https://github.com/libgit2/libgit2sharp/issues/1764
474+
Assert.InRange(reflogEntry.Committer.When, before - TimeSpan.FromSeconds(1), DateTimeOffset.Now);
471475
}
472476

473477
protected static void EnableRefLog(IRepository repository, bool enable = true)

0 commit comments

Comments
 (0)