Skip to content

Commit

Permalink
Increase assert range to avoid flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bording committed Mar 17, 2024
1 parent e170336 commit 96b8951
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,12 @@ protected static void AssertRefLogEntry(IRepository repo, string canonicalName,

Assert.Equal(committer.Email, reflogEntry.Committer.Email);

// When verifying the timestamp range, give a little more room on the 'before' side.
// When verifying the timestamp range, give a little more room on the range.
// 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);
var low = before - TimeSpan.FromSeconds(1);
var high = DateTimeOffset.Now.TruncateMilliseconds() + TimeSpan.FromSeconds(1);
Assert.InRange(reflogEntry.Committer.When, low, high);
}

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

0 comments on commit 96b8951

Please sign in to comment.