mockery 0.3.0 → 0.3.1
raw patch · 3 files changed
+25/−17 lines, 3 files
Files
- mockery.cabal +14/−13
- src/Test/Mockery/Logging.hs +3/−0
- test/Test/Mockery/LoggingSpec.hs +8/−4
mockery.cabal view
@@ -1,9 +1,9 @@--- This file has been generated from package.yaml by hpack version 0.3.0.+-- This file has been generated from package.yaml by hpack version 0.5.4. -- -- see: https://github.com/sol/hpack name: mockery-version: 0.3.0+version: 0.3.1 synopsis: Support functions for automated testing description: Support functions for automated testing category: Testing@@ -21,10 +21,9 @@ location: https://github.com/hspec/mockery library- hs-source-dirs: src- exposed-modules:- Test.Mockery.Directory- Test.Mockery.Logging+ hs-source-dirs:+ src+ ghc-options: -Wall build-depends: base == 4.* , bytestring@@ -32,16 +31,17 @@ , directory , filepath , logging-facade- ghc-options: -Wall+ exposed-modules:+ Test.Mockery.Directory+ Test.Mockery.Logging default-language: Haskell2010 test-suite spec type: exitcode-stdio-1.0- hs-source-dirs: test main-is: Spec.hs- other-modules:- Test.Mockery.DirectorySpec- Test.Mockery.LoggingSpec+ hs-source-dirs:+ test+ ghc-options: -Wall build-depends: base == 4.* , bytestring@@ -49,8 +49,9 @@ , directory , filepath , logging-facade- , mockery , hspec == 2.*- ghc-options: -Wall+ other-modules:+ Test.Mockery.DirectorySpec+ Test.Mockery.LoggingSpec default-language: Haskell2010
src/Test/Mockery/Logging.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE RecordWildCards #-} module Test.Mockery.Logging ( captureLogMessages@@ -5,7 +6,9 @@ , LogLevel(..) ) where +#if !MIN_VERSION_base(4,8,0) import Control.Applicative+#endif import Control.Exception import Data.IORef import System.Logging.Facade.Types
test/Test/Mockery/LoggingSpec.hs view
@@ -8,6 +8,9 @@ import Test.Mockery.Logging +removeLocation :: LogRecord -> LogRecord+removeLocation r = r{logRecordLocation = Nothing}+ spec :: Spec spec = describe "captureLogs" $ do let logToIORef :: IORef [LogRecord] -> LogSink@@ -17,13 +20,14 @@ (logs, ()) <- captureLogMessages $ do Log.trace "this should be captured" Log.trace "this should be captured next"- logs `shouldBe` [ (TRACE, "this should be captured")- , (TRACE, "this should be captured next")- ]+ logs `shouldBe` [+ (TRACE, "this should be captured")+ , (TRACE, "this should be captured next")+ ] it "restores the original log sink" $ do ref <- newIORef [] setLogSink $ logToIORef ref _ <- captureLogMessages $ Log.trace "this should be captured" Log.trace "this should not be captured"- readIORef ref `shouldReturn` [LogRecord TRACE Nothing "this should not be captured"]+ map removeLocation <$> readIORef ref `shouldReturn` [LogRecord TRACE Nothing "this should not be captured"]