Skip to content

Commit

Permalink
Fixed a flakey test where expires might be called right at the same t…
Browse files Browse the repository at this point in the history
…ime as the key was set to expire
  • Loading branch information
niemyjski committed Mar 20, 2024
1 parent 2350f41 commit 12051a3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/Foundatio.Tests/Caching/InMemoryCacheClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Foundatio.Caching;
Expand Down Expand Up @@ -194,7 +194,9 @@ public async Task SetAllShouldExpire()

var expiry = TimeSpan.FromMilliseconds(50);
await client.SetAllAsync(new Dictionary<string, object> { { "test", "value" } }, expiry);
await Task.Delay(expiry);

// Add 1ms to the expiry to ensure the cache has expired as the delay window is not guaranteed to be exact.
await Task.Delay(expiry.Add(TimeSpan.FromMilliseconds(1)));

Assert.False(await client.ExistsAsync("test"));
}
Expand Down

0 comments on commit 12051a3

Please sign in to comment.