Update tests
This commit is contained in:
+14
-9
@@ -18,7 +18,10 @@ import HomeAssistant.Controller (HASSEff (..), Service (..), Target(..))
|
||||
import HomeAssistant.Runtime.Bus
|
||||
import HomeAssistant.Runtime.Flags (loadFlags, setEnabled)
|
||||
import HomeAssistant.Runtime.Metrics (registerAppMetrics)
|
||||
import Katip (Namespace (Namespace), runKatipContextT, Severity (..))
|
||||
import Control.Monad.IO.Class (liftIO)
|
||||
import Katip (Namespace (Namespace), runKatipContextT)
|
||||
import Katip.Monadic (runNoLoggingT)
|
||||
import Support (withTestLogEnv)
|
||||
import qualified System.Metrics as Metrics
|
||||
import System.IO.Temp (withTempDirectory)
|
||||
import System.Timeout (timeout)
|
||||
@@ -67,8 +70,8 @@ spec = describe "Bus" $ do
|
||||
store <- Metrics.newStore
|
||||
m <- registerAppMetrics store
|
||||
withTempDirectory "/tmp" "bus-spec" $ \dir -> do
|
||||
flags <- loadFlags dir []
|
||||
withBus InfoS m flags $ \bus -> do
|
||||
flags <- runNoLoggingT (loadFlags dir [])
|
||||
withTestLogEnv $ \le -> withBus le m flags $ \bus -> do
|
||||
recordInbound bus
|
||||
recordInbound bus
|
||||
recordOutbound bus
|
||||
@@ -80,14 +83,16 @@ withTestBus :: (Bus -> IO a) -> IO a
|
||||
withTestBus action = do
|
||||
store <- Metrics.newStore
|
||||
m <- registerAppMetrics store
|
||||
withTempDirectory "/tmp" "bus-spec" $ \dir -> do
|
||||
flags <- loadFlags dir []
|
||||
withBus InfoS m flags action
|
||||
withTestLogEnv $ \le ->
|
||||
withTempDirectory "/tmp" "bus-spec" $ \dir -> do
|
||||
flags <- runNoLoggingT (loadFlags dir [])
|
||||
withBus le m flags action
|
||||
|
||||
withTestFlagsBus :: (Bus -> IO a) -> IO a
|
||||
withTestFlagsBus action = do
|
||||
store <- Metrics.newStore
|
||||
m <- registerAppMetrics store
|
||||
withTempDirectory "/tmp" "bus-spec" $ \dir -> do
|
||||
flags <- loadFlags dir ["test-handler"]
|
||||
withBus InfoS m flags action
|
||||
withTestLogEnv $ \le ->
|
||||
withTempDirectory "/tmp" "bus-spec" $ \dir -> do
|
||||
flags <- runNoLoggingT (loadFlags dir ["test-handler"])
|
||||
withBus le m flags action
|
||||
|
||||
Reference in New Issue
Block a user