fix(test): weather_map_live one-hour-cutoff test flake
The test computed recent_t = (truncated_to_top_of_hour now) - 30min, which is 30-90 min before real utc_now() depending on what minute the test runs at. The LiveView's `cutoff = utc_now() - 1h` then dropped recent_t whenever the real-time minute exceeded ~30, so the test failed half the time. Anchor recent_t at the top of the current hour — that's always within the 1-hour window regardless of minute. The test still exercises the "keep within last hour" path; just stops being clock-flaky.
This commit is contained in:
parent
139d9f7cbe
commit
2768fc68c0
1 changed files with 6 additions and 1 deletions
|
|
@ -83,7 +83,12 @@ defmodule MicrowavepropWeb.WeatherMapLiveTest do
|
||||||
|> Map.put(:second, 0)
|
|> Map.put(:second, 0)
|
||||||
|
|
||||||
stale_t = DateTime.add(now, -2 * 3600, :second)
|
stale_t = DateTime.add(now, -2 * 3600, :second)
|
||||||
recent_t = DateTime.add(now, -30 * 60, :second)
|
# `now` is truncated to the top of the hour; real `utc_now()` is up to
|
||||||
|
# 60 min ahead of that, so a `now - 30 min` recent_t is 30-90 min old
|
||||||
|
# of real time and the LiveView's `utc_now() - 1h` cutoff filters it
|
||||||
|
# out 50% of the time. Anchor recent_t at the top of the current hour
|
||||||
|
# — that's always within the 1-hour window regardless of minute.
|
||||||
|
recent_t = now
|
||||||
future_t = DateTime.add(now, 3 * 3600, :second)
|
future_t = DateTime.add(now, 3 * 3600, :second)
|
||||||
|
|
||||||
Enum.each([stale_t, recent_t, future_t], &write_profile(&1, 33.0, -97.0))
|
Enum.each([stale_t, recent_t, future_t], &write_profile(&1, 33.0, -97.0))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue