Fix plan: hspec-hedgehog bridge, import lists

This commit is contained in:
2026-08-20 19:25:17 +03:00
parent 3a4b42e3a7
commit aa5a91bfa3
@@ -160,7 +160,7 @@ import Control.Concurrent.STM
, writeTChan , writeTChan
) )
import Data.Aeson (Value) import Data.Aeson (Value)
import Data.IORef (IORef, atomicModifyIORef', newIORef) import Data.IORef (atomicModifyIORef', newIORef)
import HomeAssistant.Controller (HASSEff (..), Service) import HomeAssistant.Controller (HASSEff (..), Service)
import Network.WebSockets (Connection) import Network.WebSockets (Connection)
@@ -196,7 +196,7 @@ mkCallIdGen start = do
Then in `src/HomeAssistant/Runtime.hs`: Then in `src/HomeAssistant/Runtime.hs`:
- Delete the local `newtype CallIdGen`/`mkCallIdGen` definitions (lines 105110). - Delete the local `newtype CallIdGen`/`mkCallIdGen` definitions (lines 105110).
- Add import: `import HomeAssistant.Runtime.Bus (Bus(..), CallIdGen(..), mkCallIdGen)`. - Add import: `import HomeAssistant.Runtime.Bus (CallIdGen(..), mkCallIdGen)`.
- Export list stays the same (`CallIdGen`, `mkCallIdGen` now re-exported from Bus). - Export list stays the same (`CallIdGen`, `mkCallIdGen` now re-exported from Bus).
- [ ] **Step 4: Regenerate the nix derivation** - [ ] **Step 4: Regenerate the nix derivation**
@@ -241,7 +241,7 @@ git commit -m "Add Runtime.Bus with channel-based effect interpreter"
```haskell ```haskell
module ConnectionSpec (spec) where module ConnectionSpec (spec) where
import Data.Aeson (Value, object, (.=)) import Data.Aeson (object, (.=))
import Data.Text (Text) import Data.Text (Text)
import HomeAssistant.Controller (Service (..)) import HomeAssistant.Controller (Service (..))
import HomeAssistant.Runtime.Connection (encodeService) import HomeAssistant.Runtime.Connection (encodeService)
@@ -657,15 +657,15 @@ spec = describe "supervised" $ do
module BackoffProp (spec) where module BackoffProp (spec) where
import Data.Time (NominalDiffTime) import Data.Time (NominalDiffTime)
import Hedgehog
import qualified Hedgehog.Gen as Gen import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range import qualified Hedgehog.Range as Range
import HomeAssistant.Runtime.Supervisor (Backoff (..), backoffDelay) import HomeAssistant.Runtime.Supervisor (Backoff (..), backoffDelay)
import Test.Hspec (Spec, describe) import Test.Hspec (Spec, describe, it)
import Test.Hspec.Hedgehog (hedgehog, forAll, (===))
spec :: Spec spec :: Spec
spec = describe "backoffDelay" $ spec = describe "backoffDelay" $
prop "doubles from base, clamped at cap" $ property $ do it "doubles from base, clamped at cap" $ hedgehog $ do
baseD <- forAll $ Gen.double (Range.constant 0.0001 10) baseD <- forAll $ Gen.double (Range.constant 0.0001 10)
ratio <- forAll $ Gen.double (Range.constant 1 100) ratio <- forAll $ Gen.double (Range.constant 1 100)
let base = realToFrac baseD :: NominalDiffTime let base = realToFrac baseD :: NominalDiffTime
@@ -676,7 +676,10 @@ spec = describe "backoffDelay" $
mapM_ (\(a, b) -> b === min cap (a * 2)) (zip delays (drop 1 delays)) mapM_ (\(a, b) -> b === min cap (a * 2)) (zip delays (drop 1 delays))
``` ```
`test/Main.hs`: add imports and run all five specs. Cabal: library `exposed-modules` += `HomeAssistant.Runtime.Supervisor`, library `build-depends` += `annotated-exception`; test `other-modules` += `SupervisorSpec, BackoffProp`, test `build-depends` += `hedgehog, annotated-exception, time`. (`hspec-hedgehog` provides the `hedgehog` bridge — plain hedgehog 1.5 has
no hspec integration — and re-exports `forAll` and `(===)`.)
`test/Main.hs`: add imports and run all five specs. Cabal: library `exposed-modules` += `HomeAssistant.Runtime.Supervisor`, library `build-depends` += `annotated-exception`; test `other-modules` += `SupervisorSpec, BackoffProp`, test `build-depends` += `hedgehog, hspec-hedgehog, annotated-exception, time`.
- [ ] **Step 2: Run tests to verify they fail** - [ ] **Step 2: Run tests to verify they fail**