36 lines
1.2 KiB
Haskell
Raw Normal View History

module Main where
import MiniStack.Rollout
( Environment (Production)
, RolloutError (RestrictedService)
, RolloutSummary (RolloutSummary)
, defaultEnv
, parseRequest
, renderLog
, renderSummary
, runRollout
)
import System.Exit (die)
main :: IO ()
main =
case (parseRequest "api:production:4", parseRequest "billing:production:2") of
( Right allowedRequest
, Right deniedRequest
) ->
case (runRollout defaultEnv allowedRequest, runRollout defaultEnv deniedRequest) of
( (Right summary, allowedLog)
, (Left (RestrictedService "billing"), deniedLog)
) | renderSummary summary == "api -> production, cluster europe-west, replicas 4"
&& lines (renderLog allowedLog)
== [ "start rollout for api"
, "service is allowed in production"
, "replica limit ok: 6"
, "deploy to cluster europe-west"
, "set replicas to 4"
]
&& lines (renderLog deniedLog) == ["start rollout for billing"] ->
putStrLn "test passed"
_ -> die "unexpected transformer stack result"
_ -> die "unexpected rollout parse result"