Make flag-decision tests fail fast and assert the outbound metric
This commit is contained in:
@@ -3,9 +3,8 @@
|
||||
module ConnectionSpec (spec) where
|
||||
|
||||
import AFRP (Request(..))
|
||||
import Control.Monad.IO.Class (liftIO)
|
||||
import Data.Aeson (object, (.=))
|
||||
import Data.Foldable (forM_)
|
||||
import qualified Data.HashMap.Strict as HM
|
||||
import Data.Maybe (fromJust)
|
||||
import Data.Text (Text)
|
||||
import Data.Time (UTCTime (..), utc)
|
||||
@@ -19,6 +18,7 @@ import HomeAssistant.Runtime.Connection (dispatchService, encodeService, isTrigg
|
||||
import Katip (Namespace (Namespace), Severity (InfoS), runKatipContextT)
|
||||
import System.IO.Temp (withTempDirectory)
|
||||
import qualified System.Metrics as Metrics
|
||||
import System.Timeout (timeout)
|
||||
import Test.Hspec
|
||||
|
||||
spec :: Spec
|
||||
@@ -63,10 +63,12 @@ spec = do
|
||||
flags <- loadFlags dir ["test"]
|
||||
setEnabled flags "test" False
|
||||
withBus InfoS m flags $ \bus -> do
|
||||
runKatipContextT (busLogEnv bus) () (Namespace ["connection"]) $
|
||||
dispatchService limiter bus (req 1) (lightOn [EntityId "light.test"])
|
||||
generateCallId (busGen bus) `shouldReturn` 1
|
||||
|
||||
timeout 1000000 (do
|
||||
runKatipContextT (busLogEnv bus) () (Namespace ["connection"]) $
|
||||
dispatchService limiter bus (req 1) (lightOn [EntityId "light.test"])
|
||||
generateCallId (busGen bus)) `shouldReturn` Just 1
|
||||
sample <- Metrics.sampleAll store
|
||||
HM.lookup "hass.service.out" sample `shouldBe` Just (Metrics.Counter 0)
|
||||
|
||||
req :: Int -> Request
|
||||
req n = Request (UTCTime (toEnum 0) (fromIntegral (0 :: Int))) utc
|
||||
|
||||
Reference in New Issue
Block a user