keiro-dsl-0.2.0.0: test/conformance-skeletons/SkelAggregate/Generated/MyService/Thing/Harness.hs
{-# LANGUAGE OverloadedStrings #-}
-- @generated by keiro-dsl; do not edit. Regenerated from the .keiro spec.
module SkelAggregate.Generated.MyService.Thing.Harness (harnessAssertions) where
import Keiki.Core (defaultValidationOptions, step, validateTransducer)
import Keiro.Codec (eventType)
import SkelAggregate.Generated.MyService.Thing.Codec (encodeThingEvent, parseThingEvent, thingCodec)
import SkelAggregate.Generated.MyService.Thing.Domain
import SkelAggregate.MyService.Thing.Holes (thingTransducer)
{- | (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 thingTransducer))
, ("clock-free: spec samples no wall clock", True)
, ("golden round-trip: ThingCompleted", roundTrips sampleEventThingCompleted)
, ("accepts DoThing from ThingPending", acceptDoThing)
]
roundTrips :: ThingEvent -> Bool
roundTrips e = parseThingEvent (eventType thingCodec e) (encodeThingEvent e) == Right e
sampleEventThingCompleted :: ThingEvent
sampleEventThingCompleted = (ThingCompleted (ThingCompletedData (ThingId "sample") 0))
acceptDoThing :: Bool
acceptDoThing =
case step thingTransducer (ThingPending, initialThingRegs) ((DoThing (DoThingData (ThingId "sample") 0))) of
Just (v, _, _) -> v == ThingDone
Nothing -> False