30 lines
986 B
Haskell
30 lines
986 B
Haskell
module Main where
|
|
|
|
import Data.List.NonEmpty (NonEmpty ((:|)))
|
|
import qualified Data.List.NonEmpty as NonEmpty
|
|
import MiniWaves.Plan
|
|
( Environment (Production, Staging)
|
|
, ReleaseMode (Canary, Rolling)
|
|
, RolloutPlan (RolloutPlan)
|
|
, Wave (Wave)
|
|
, buildPlan
|
|
, parseJob
|
|
, renderPlan
|
|
)
|
|
import System.Exit (die)
|
|
|
|
main :: IO ()
|
|
main =
|
|
case (parseJob "api:production:canary:20:6", parseJob "worker:staging:rolling:0:2") of
|
|
( Right canaryJob
|
|
, Right rollingJob
|
|
) ->
|
|
case (buildPlan canaryJob, buildPlan rollingJob) of
|
|
( RolloutPlan "api" Production (Wave "canary" 20 3 :| [Wave "steady" 100 6])
|
|
, RolloutPlan "worker" Staging (Wave "full" 100 2 :| [])
|
|
) | "worker -> staging, waves 1, first full, last full"
|
|
`elem` lines (renderPlan (buildPlan rollingJob)) ->
|
|
putStrLn "test passed"
|
|
_ -> die "unexpected NonEmpty wave plan"
|
|
_ -> die "unexpected rollout parse result"
|