Skip to content
Permalink
Browse files

Improve stability of AssertRefLogEntry-based tests

Fixes #1764
  • Loading branch information
AArnott committed Jan 31, 2020
1 parent 7e40e96 commit 972f78ac9d96419ef234b3ea0f4e84492d4cf172
Showing with 5 additions and 1 deletion.
  1. +5 −1 LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
@@ -467,7 +467,11 @@ protected string Expected(string filenameFormat, params object[] args)
Assert.Equal(@from ?? ObjectId.Zero, reflogEntry.From);

Assert.Equal(committer.Email, reflogEntry.Committer.Email);
Assert.InRange(reflogEntry.Committer.When, before, DateTimeOffset.Now);

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

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

0 comments on commit 972f78a

Please sign in to comment.
You can’t perform that action at this time.