fix flaky test
This commit is contained in:
parent
cc60c1991f
commit
1a9a27156b
1 changed files with 15 additions and 5 deletions
|
|
@ -5320,8 +5320,18 @@ test "recheck floor: once the interval has passed, the symbol is asked again" {
|
|||
var store = svc.store();
|
||||
const spec = DataService.dividendTtl(divs[0..]);
|
||||
|
||||
// One second inside the interval -> still served.
|
||||
writeAged(Dividend, &store, "TEST", divs[0..], spec, DataService.smart_refresh_recheck_interval - 1);
|
||||
// A MINUTE either side, not a second. `writeAged` stamps `expires` off
|
||||
// the wall clock at write time and `askedRecently` recovers the age off
|
||||
// the wall clock at read time, so the entry ages by however long the gap
|
||||
// between the two takes. At one second that gap was the margin: under
|
||||
// kcov the instrumented binary occasionally crossed a second boundary,
|
||||
// the "inside" entry read as 12h old, the refetch went ahead, and the
|
||||
// network assertion panicked the coverage run. A minute is far beyond
|
||||
// any real gap and still nothing against a 12-hour interval.
|
||||
const margin: i64 = 60;
|
||||
|
||||
// Inside the interval -> still served.
|
||||
writeAged(Dividend, &store, "TEST", divs[0..], spec, DataService.smart_refresh_recheck_interval - margin);
|
||||
{
|
||||
svc.panic_on_network_attempt = true;
|
||||
const held = try svc.getDividends("TEST", .{});
|
||||
|
|
@ -5330,9 +5340,9 @@ test "recheck floor: once the interval has passed, the symbol is asked again" {
|
|||
svc.panic_on_network_attempt = false;
|
||||
}
|
||||
|
||||
// One second past it -> asked again (NoApiKey proves we got to the
|
||||
// provider rather than being served the cache).
|
||||
writeAged(Dividend, &store, "TEST", divs[0..], spec, DataService.smart_refresh_recheck_interval + 1);
|
||||
// Past it -> asked again (NoApiKey proves we got to the provider rather
|
||||
// than being served the cache).
|
||||
writeAged(Dividend, &store, "TEST", divs[0..], spec, DataService.smart_refresh_recheck_interval + margin);
|
||||
try std.testing.expectError(DataError.NoApiKey, svc.getDividends("TEST", .{}));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue