Clean hlint and cabal warnings
This commit is contained in:
@@ -12,6 +12,10 @@ import Support (fakeRequest)
|
||||
import Test.Hspec (Spec, describe, it)
|
||||
import Test.Hspec.Hedgehog (forAll, forAllWith, hedgehog, (===))
|
||||
|
||||
-- We are testing laws -> hlint warns about not using laws
|
||||
{-# ANN module "Hlint: ignore" #-}
|
||||
|
||||
|
||||
-- | Law tests for the Mealy instances. Two machines count as equal when
|
||||
-- they emit equal outputs on every input sequence, so each law runs both
|
||||
-- sides on generated inputs.
|
||||
|
||||
+3
-2
@@ -19,6 +19,7 @@ import qualified Hedgehog.Gen as Gen
|
||||
import qualified Hedgehog.Range as Range
|
||||
import Test.Hspec
|
||||
import Test.Hspec.Hedgehog
|
||||
import Data.Maybe (listToMaybe)
|
||||
|
||||
fakeRequest :: Request
|
||||
fakeRequest = Request (sec 0) utc nil "test"
|
||||
@@ -52,7 +53,7 @@ instance Functor St where
|
||||
fmap f (St g) = St $ \s -> let (a, s') = g s in (f a, s')
|
||||
|
||||
instance Applicative St where
|
||||
pure a = St (\s -> (a, s))
|
||||
pure a = St (a,)
|
||||
St f <*> St x = St $ \s -> let (f', s') = f s; (a, s'') = x s' in (f' a, s'')
|
||||
|
||||
instance Monad St where
|
||||
@@ -165,7 +166,7 @@ lMergeSpec = describe "lMerge" $ do
|
||||
changesSpec :: Spec
|
||||
changesSpec = describe "changes" $ do
|
||||
it "first output is always Tick" $
|
||||
runPure changes "hello" !! 0 `shouldBe` Tick
|
||||
listToMaybe (runPure changes "hello") `shouldBe` Just Tick
|
||||
|
||||
it "outputs Event only on value change" $
|
||||
runPure changes "aaaabbbcca"
|
||||
|
||||
+1
-2
@@ -6,7 +6,7 @@ import AFRP (Request (..), Event (..))
|
||||
import Control.Concurrent.STM
|
||||
( atomically
|
||||
, dupTChan
|
||||
, isEmptyTChan
|
||||
|
||||
, readTChan
|
||||
, writeTChan
|
||||
)
|
||||
@@ -18,7 +18,6 @@ import HomeAssistant.Controller (HASSEff (..), Service (..), Target(..))
|
||||
import HomeAssistant.Runtime.Bus
|
||||
import HomeAssistant.Runtime.Flags (loadFlags, setEnabled)
|
||||
import HomeAssistant.Runtime.Metrics (registerAppMetrics)
|
||||
import Control.Monad.IO.Class (liftIO)
|
||||
import Katip (Namespace (Namespace), runKatipContextT)
|
||||
import Katip.Monadic (runNoLoggingT)
|
||||
import Support (withTestLogEnv)
|
||||
|
||||
@@ -80,7 +80,5 @@ req n = Request (UTCTime (toEnum 0) (fromIntegral (0 :: Int))) utc
|
||||
uuid = "00000000-0000-0000-0000-" <> pad n
|
||||
|
||||
lightOn :: [Target] -> Service
|
||||
lightOn targets = Service "light" "turn_on" Nothing targets
|
||||
lightOn = Service "light" "turn_on" Nothing
|
||||
|
||||
lightOff :: [Target] -> Service
|
||||
lightOff targets = Service "light" "turn_off" Nothing targets
|
||||
|
||||
@@ -4,7 +4,6 @@ import Test.Hspec
|
||||
import Data.Default (def)
|
||||
import HomeAssistant.Controller (Brightness(..), formatLightAttributes, LightAttributes(..))
|
||||
import Data.Aeson (object, (.=))
|
||||
import HomeAssistant.Controller ()
|
||||
|
||||
|
||||
spec :: Spec
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ spec = describe "Flags" $ do
|
||||
n <- forAll $ Gen.int (Range.linear 1 50)
|
||||
liftIO $ withTempDirectory "/tmp" "flags-spec" $ \dir -> do
|
||||
flags <- runNoLoggingT (loadFlags dir ["x"])
|
||||
mapConcurrently_ (\i -> setEnabled flags "x" (even i)) [1 .. n]
|
||||
mapConcurrently_ (setEnabled flags "x" . even) [1 .. n]
|
||||
m <- allFlags flags
|
||||
decoded <- decodeFileStrict (dir <> "/handlers.json")
|
||||
(decoded :: Maybe (Map Text Bool)) `shouldBe` Just m
|
||||
|
||||
@@ -7,6 +7,7 @@ import qualified Data.ByteString as BS
|
||||
import HomeAssistant.Runtime.Graphing
|
||||
( GraphSpec (..)
|
||||
, Range (..)
|
||||
, Graph(..)
|
||||
, buildGraphArgs
|
||||
, graphs
|
||||
, lookupGraph
|
||||
@@ -21,7 +22,6 @@ import System.Exit (ExitCode (..))
|
||||
import System.Process (readProcessWithExitCode)
|
||||
import Test.Hspec
|
||||
import Servant.API (FromHttpApiData(..), ToHttpApiData (..))
|
||||
import HomeAssistant.Runtime.Graphing (Graph(..))
|
||||
|
||||
traffic :: GraphSpec
|
||||
traffic = case lookupGraph graphs Traffic of
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ spec = do
|
||||
parseInfoDs "step = 10\nrra[0].cf = \"AVERAGE\"\n" `shouldBe` []
|
||||
|
||||
describe "schemaMatches" $ do
|
||||
let ds name ty = DsSpec (T.pack name) name ty
|
||||
let ds name = DsSpec (T.pack name) name
|
||||
it "is true for identical schemas regardless of order" $
|
||||
schemaMatches [ds "b" Gauge, ds "a" Derive] [("a", Derive), ("b", Gauge)]
|
||||
`shouldBe` True
|
||||
|
||||
+2
-1
@@ -36,7 +36,7 @@ instance Functor Acc where
|
||||
fmap f (Acc g) = Acc $ \s -> let (a, s') = g s in (f a, s')
|
||||
|
||||
instance Applicative Acc where
|
||||
pure a = Acc (\s -> (a, s))
|
||||
pure a = Acc (a,)
|
||||
Acc f <*> Acc x = Acc $ \s -> let (f', s') = f s; (a, s'') = x s' in (f' a, s'')
|
||||
|
||||
instance Monad Acc where
|
||||
@@ -52,6 +52,7 @@ withTestLogEnv = bracket (initLogEnv "test" "test") closeScribes
|
||||
-- | Interpret `HASSEff` in `Acc`: record `CallService`, drop tracing/debug.
|
||||
interp :: HASSEff a -> Acc a
|
||||
interp (CallService _ svc) = Acc $ \s -> ((), s ++ [svc])
|
||||
interp (CallServices _ svc) = Acc $ \s -> ((), s ++ svc)
|
||||
interp (Debug _) = pure ()
|
||||
interp (Trace _ _) = pure ()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user