diff options
Diffstat (limited to 'test/test_weather.lua')
| -rw-r--r-- | test/test_weather.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_weather.lua b/test/test_weather.lua index 95908ce..cdcdc2d 100644 --- a/test/test_weather.lua +++ b/test/test_weather.lua @@ -222,4 +222,15 @@ assert(weather.age_str(1000, 1000 + 3600) == '1h', 'an hour reads as 1h') assert(weather.age_str(1000, 1000 + 7200) == '2h', 'two hours') assert(weather.age_str(1000, 1000 + 86400 * 2) == '2d', 'days, once it gets that bad') +-- Neither takes `now` on faith: a nil there used to raise, and a raise is a +-- blank dashboard rather than a message. +assert(weather.is_stale(1000, nil) == true, 'a nil now must not raise') +assert(weather.age_str(1000, nil) == '?', 'a nil now must not raise') + +-- A dt in the future means a clock skew. "stale -17m" reads as a broken +-- widget, so the age floors at zero and the reading counts as fresh. +assert(weather.age_str(2000, 1000) == '0m', 'a future dt reads as 0m, got ' .. + tostring(weather.age_str(2000, 1000))) +assert(weather.is_stale(2000, 1000) == false, 'a future dt is not stale') + print('test_weather: all assertions passed') |
