module Main where import qualified Data.Map.Strict as Map import MiniDependency.Order ( Catalog , DeploymentStep (DeploymentStep) , ServiceProfile (ServiceProfile) , catalog , renderPlan , resolveDeploymentOrder ) import System.Exit (die) cyclicCatalog :: Catalog cyclicCatalog = Map.fromList [ ("a", ServiceProfile ["b"] False) , ("b", ServiceProfile ["a"] False) ] main :: IO () main = case ( resolveDeploymentOrder catalog ["frontend", "billing"] , resolveDeploymentOrder cyclicCatalog ["a"] ) of ( Right [ DeploymentStep "postgres" [] False , DeploymentStep "auth" ["postgres"] True , DeploymentStep "redis" [] False , DeploymentStep "api" ["auth", "redis"] True , DeploymentStep "frontend" ["api"] False , DeploymentStep "billing" ["api", "postgres"] True ] , Left _ ) | "billing, deps api, postgres, migration yes" `elem` lines ( renderPlan [ DeploymentStep "postgres" [] False , DeploymentStep "auth" ["postgres"] True , DeploymentStep "redis" [] False , DeploymentStep "api" ["auth", "redis"] True , DeploymentStep "frontend" ["api"] False , DeploymentStep "billing" ["api", "postgres"] True ] ) -> putStrLn "test passed" _ -> die "unexpected dependency-order result"