From a77b85b57634d344d5f2ae31ed74f04bb18f73a8 Mon Sep 17 00:00:00 2001 From: Mats Rauhala Date: Fri, 21 Aug 2026 13:29:16 +0300 Subject: [PATCH] Update tests --- .gitignore | 2 ++ test/BusSpec.hs | 3 ++- test/RuntimeSpec.hs | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index de5ce15..faf5b4b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ dist-newstyle .direnv .worktrees/ + +docs/superpowers diff --git a/test/BusSpec.hs b/test/BusSpec.hs index a36b797..30c2cc0 100644 --- a/test/BusSpec.hs +++ b/test/BusSpec.hs @@ -34,7 +34,8 @@ spec = describe "Bus" $ do svc = Service "light" "turn_on" Nothing [EntityId "light.bedroom_masse"] runKatipContextT (busLogEnv bus) () (Namespace ["test"]) $ channelHassEval bus (CallService req svc) - atomically (readTChan (busOutbound bus)) `shouldReturn` svc + (_, svc') <- atomically $ readTChan (busOutbound bus) + svc' `shouldBe` svc it "generates unique sequential call ids" $ do diff --git a/test/RuntimeSpec.hs b/test/RuntimeSpec.hs index 59e6742..c1b1c85 100644 --- a/test/RuntimeSpec.hs +++ b/test/RuntimeSpec.hs @@ -22,11 +22,11 @@ spec = describe "runController" $ do atomically $ writeTChan (busInbound bus) (doorEvent "off") -- door closes: lights on atomically $ writeTChan (busInbound bus) (doorEvent "on") -- door opens: lights off putStrLn "After the writes" - svc1 <- boundedRead (busOutbound bus) - svc2 <- boundedRead (busOutbound bus) + Right (_, svc1) <- boundedRead (busOutbound bus) + Right (_, svc2) <- boundedRead (busOutbound bus) putStrLn "After the reads" - svc1 `shouldBe` Right (light [EntityId "light.bedroom_masse"] True) - svc2 `shouldBe` Right (light [EntityId "light.bedroom_masse"] False) + svc1 `shouldBe` light [EntityId "light.bedroom_masse"] True + svc2 `shouldBe` light [EntityId "light.bedroom_masse"] False atomically (isEmptyTChan (busOutbound bus)) `shouldReturn` True where boundedRead channel = race (threadDelay 10000) (atomically (readTChan channel))