39 lines
1.1 KiB
Haskell
39 lines
1.1 KiB
Haskell
module Main where
|
|
|
|
import MiniSummary.Report
|
|
( Count (Count)
|
|
, DeploymentSummary (..)
|
|
, LargestReplicas (LargestReplicas)
|
|
, parseEvent
|
|
, renderSummary
|
|
, summarizeEvents
|
|
)
|
|
import qualified Data.Set as Set
|
|
import System.Exit (die)
|
|
|
|
main :: IO ()
|
|
main =
|
|
case
|
|
traverse
|
|
parseEvent
|
|
[ "api:production:succeeded:3:platform,security"
|
|
, "worker:staging:failed-db-lock:1:ops"
|
|
, "ui:production:cancelled:2:frontend"
|
|
] of
|
|
Left err -> die err
|
|
Right events ->
|
|
case summarizeEvents events of
|
|
DeploymentSummary
|
|
{ totalDeployments = Count 3
|
|
, productionDeployments = Count 2
|
|
, totalReplicas = Count 6
|
|
, failedServices = failedServicesSet
|
|
, activeOwners = ownerSet
|
|
, largestReplicaCount = LargestReplicas 3
|
|
}
|
|
| failedServicesSet == Set.fromList ["worker"]
|
|
&& ownerSet == Set.fromList ["frontend", "ops", "platform", "security"]
|
|
&& "cancelled seen: yes" `elem` lines (renderSummary (summarizeEvents events)) ->
|
|
putStrLn "test passed"
|
|
_ -> die "unexpected foldMap summary result"
|