packages feed

keiro-dsl-0.2.0.0: test/conformance-skeletons/SkelProcess/Generated/MyService/Hospital/Harness.hs

{-# LANGUAGE OverloadedStrings #-}

-- @generated by keiro-dsl; do not edit. Regenerated from the .keiro spec.
module SkelProcess.Generated.MyService.Hospital.Harness (harnessAssertions) where

import Keiki.Core (defaultValidationOptions, step, validateTransducer)
import Keiro.Codec (eventType)
import SkelProcess.Generated.MyService.Hospital.Codec (encodeHospitalEvent, hospitalCodec, parseHospitalEvent)
import SkelProcess.Generated.MyService.Hospital.Domain
import SkelProcess.MyService.Hospital.Holes (hospitalTransducer)

{- | (label, passed). A driver runs these and exits non-zero on any False,
naming the failing assertion. Filling a hole wrongly turns a specific
entry False; the scaffold cannot.
-}
harnessAssertions :: [(String, Bool)]
harnessAssertions =
    [ ("validateTransducer is empty", null (validateTransducer defaultValidationOptions hospitalTransducer))
    , ("clock-free: spec samples no wall clock", True)
    , ("golden round-trip: SurgeActivated", roundTrips sampleEventSurgeActivated)
    , ("accepts ActivateSurge from HospitalOperational", acceptActivateSurge)
    ]

roundTrips :: HospitalEvent -> Bool
roundTrips e = parseHospitalEvent (eventType hospitalCodec e) (encodeHospitalEvent e) == Right e

sampleEventSurgeActivated :: HospitalEvent
sampleEventSurgeActivated = (SurgeActivated (SurgeActivatedData (HospitalId "sample")))

acceptActivateSurge :: Bool
acceptActivateSurge =
    case step hospitalTransducer (HospitalOperational, initialHospitalRegs) ((ActivateSurge (ActivateSurgeData (HospitalId "sample")))) of
        Just (v, _, _) -> v == HospitalSurging
        Nothing -> False