From af9f96f3f1f93b28018b7607b2c0866f06f17505 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 4 Nov 2020 15:57:20 +0100 Subject: [PATCH] chore: fix tests & refactor --- src/Mail.hs | 4 +--- test/MailSpec.hs | 4 +--- test/ModelSpec.hs | 10 +++++++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Mail.hs b/src/Mail.hs index bdc19a0e5..41e946f0d 100644 --- a/src/Mail.hs +++ b/src/Mail.hs @@ -50,7 +50,7 @@ import Settings.Mime import Data.Monoid (Last(..)) import Control.Monad.Trans.RWS (RWST(..)) import Control.Monad.Trans.State (StateT(..), execStateT, mapStateT) -import Control.Monad.Trans.Writer (execWriter, Writer) +import Control.Monad.Trans.Writer (execWriter, execWriterT, Writer) import Control.Monad.RWS.Class (MonadWriter(..), MonadState(..), modify) import Control.Monad.Fail import Control.Monad.Base @@ -124,8 +124,6 @@ import Language.Haskell.TH (nameBase) import Network.Mail.Mime.Instances() -import Control.Monad.Trans.Writer (execWriterT) - makeLenses_ ''Address makeLenses_ ''Mail diff --git a/test/MailSpec.hs b/test/MailSpec.hs index b386d3972..b82f4b60a 100644 --- a/test/MailSpec.hs +++ b/test/MailSpec.hs @@ -14,7 +14,7 @@ instance Arbitrary MailContext where arbitrary = genericArbitrary shrink = genericShrink -instance Arbitrary VerpMode where +instance Arbitrary Address where arbitrary = genericArbitrary shrink = genericShrink @@ -25,5 +25,3 @@ spec = do [ eqLaws, ordLaws, showReadLaws, monoidLaws ] lawsCheckHspec (Proxy @MailContext) [ eqLaws, ordLaws, showReadLaws, jsonLaws, hashableLaws ] - lawsCheckHspec (Proxy @VerpMode) - [ eqLaws, showReadLaws, jsonLaws ] diff --git a/test/ModelSpec.hs b/test/ModelSpec.hs index cb7708b2f..fcb380fa3 100644 --- a/test/ModelSpec.hs +++ b/test/ModelSpec.hs @@ -5,9 +5,10 @@ module ModelSpec where import TestImport -import Settings (getTimeLocale') +import Settings (getTimeLocale', VerpMode(..)) import Model.TypesSpec () +import MailSpec () import qualified Data.CaseInsensitive as CI import qualified Data.ByteString.Char8 as CBS @@ -203,6 +204,11 @@ instance {-# OVERLAPS #-} (HasCryptoID ns ct pt (ReaderT CryptoIDKey Catch), Arb where tmpKey = unsafePerformIO genKey +instance Arbitrary VerpMode where + arbitrary = genericArbitrary + shrink = genericShrink + + spec :: Spec spec = do parallel $ do @@ -214,3 +220,5 @@ spec = do [ eqLaws ] lawsCheckHspec (Proxy @Term) [ eqLaws, jsonLaws ] + lawsCheckHspec (Proxy @VerpMode) + [ eqLaws, showReadLaws, jsonLaws ]