41 lines
1.3 KiB
Haskell
41 lines
1.3 KiB
Haskell
module Main where
|
|
|
|
import Data.Time (secondsToNominalDiffTime)
|
|
import MiniTimeWindows.Window
|
|
( WindowStatus (Active, NoMoreWindows, Waiting)
|
|
, parseInstant
|
|
, renderStatus
|
|
, sampleWindows
|
|
, statusAt
|
|
)
|
|
import System.Exit (die)
|
|
|
|
main :: IO ()
|
|
main =
|
|
case
|
|
( parseInstant "2026-05-05T10:30:00Z"
|
|
, parseInstant "2026-05-05T11:45:00Z"
|
|
, parseInstant "2026-05-05T17:00:00Z"
|
|
, parseInstant "not-a-time"
|
|
) of
|
|
( Right activeInstant
|
|
, Right waitingInstant
|
|
, Right finishedInstant
|
|
, Left _
|
|
) ->
|
|
case
|
|
( statusAt activeInstant sampleWindows
|
|
, statusAt waitingInstant sampleWindows
|
|
, statusAt finishedInstant sampleWindows
|
|
) of
|
|
( Active activeWindow remainingTime
|
|
, Waiting waitingWindow delay
|
|
, NoMoreWindows
|
|
) | renderStatus (Active activeWindow remainingTime) == "active schema-migration for 30m more"
|
|
&& renderStatus (Waiting waitingWindow delay) == "next billing-freeze starts in 45m"
|
|
&& remainingTime == secondsToNominalDiffTime 1800
|
|
&& delay == secondsToNominalDiffTime 2700 ->
|
|
putStrLn "test passed"
|
|
_ -> die "unexpected Data.Time status result"
|
|
_ -> die "unexpected Data.Time parse result"
|