Update tests

This commit is contained in:
MasseR committed 2026-09-12 20:18:13 +03:00
1 parent b20320c779
commit a3dd63f26c
4 files changed
+38 -54

No files matched your search

+7 -7
View File
@@ -16,9 +16,8 @@ import Data.Aeson (Value, object, (.=))
import qualified Data.Text as T
import Data.Time (UTCTime (..), utc)
import Data.UUID (nil)
import AFRP (Mealy (..), Pair (..), Request (..))
import AFRP (Mealy (..), Request (..), stepAuto)
import HomeAssistant.Controller (HASSEff (..), Service)
import AFRP (stepAuto)
fakeRequest :: Request
fakeRequest = Request (sec 0) utc nil
@@ -50,11 +49,12 @@ interp (Trace _ _) = pure ()
-- | Run a HASS arrow over a list of inputs, collecting per-step emitted services.
runHASS :: Mealy HASSEff a b -> [a] -> [(b, [Service])]
runHASS _ [] = []
runHASS m (a : as) =
let w = runMealy m interp
in case runAcc (stepAuto w fakeRequest a) [] of
(Pair b m', svcs) -> (b, svcs) : runHASS m' as
runHASS m = go (runMealy m interp)
where
go _ [] = []
go w (a : as) =
case runAcc (stepAuto w fakeRequest a) [] of
((b, w'), svcs) -> (b, svcs) : go w' as
services :: [(b, [Service])] -> [[Service]]
services = map snd