36 lines
913 B
Haskell
36 lines
913 B
Haskell
|
|
{-# LANGUAGE OverloadedStrings #-}
|
||
|
|
|
||
|
|
module Main where
|
||
|
|
|
||
|
|
import MiniGenericJson.Manifest
|
||
|
|
( ReleaseManifest (..)
|
||
|
|
, Environment (Production)
|
||
|
|
, RolloutStrategy (Stable, Canary)
|
||
|
|
, decodeManifest
|
||
|
|
, encodeManifest
|
||
|
|
, renderManifest
|
||
|
|
)
|
||
|
|
import System.Exit (die)
|
||
|
|
|
||
|
|
sampleManifest :: ReleaseManifest
|
||
|
|
sampleManifest =
|
||
|
|
ReleaseManifest
|
||
|
|
{ manifestService = "api"
|
||
|
|
, manifestEnvironment = Production
|
||
|
|
, manifestReplicas = 3
|
||
|
|
, manifestOwners = ["platform", "security"]
|
||
|
|
, manifestStrategy = Canary 10
|
||
|
|
}
|
||
|
|
|
||
|
|
main :: IO ()
|
||
|
|
main =
|
||
|
|
case
|
||
|
|
( decodeManifest (encodeManifest sampleManifest)
|
||
|
|
, decodeManifest "{\"service\":\"api\"}"
|
||
|
|
) of
|
||
|
|
( Right decodedManifest
|
||
|
|
, Left _
|
||
|
|
) | renderManifest decodedManifest == "service api, env production, replicas 3, owners platform/security, strategy canary 10%" ->
|
||
|
|
putStrLn "test passed"
|
||
|
|
_ -> die "unexpected generic JSON result"
|