packages feed

mockery 0.2.0 → 0.2.1

raw patch · 4 files changed

+47/−3 lines, 4 filesdep +bytestringPVP ok

version bump matches the API change (PVP)

Dependencies added: bytestring

API changes (from Hackage documentation)

+ Test.Mockery.Directory: touch :: FilePath -> IO ()
+ Test.Mockery.Logging: DEBUG :: LogLevel
+ Test.Mockery.Logging: ERROR :: LogLevel
+ Test.Mockery.Logging: INFO :: LogLevel
+ Test.Mockery.Logging: TRACE :: LogLevel
+ Test.Mockery.Logging: WARN :: LogLevel
+ Test.Mockery.Logging: data LogLevel :: *

Files

mockery.cabal view
@@ -1,9 +1,9 @@--- This file has been generated from package.yaml by hpack version 0.1.2.+-- This file has been generated from package.yaml by hpack version 0.3.0. -- -- see: https://github.com/sol/hpack  name:           mockery-version:        0.2.0+version:        0.2.1 synopsis:       Support functions for automated testing description:    Support functions for automated testing category:       Testing@@ -27,6 +27,7 @@       Test.Mockery.Logging   build-depends:       base == 4.*+    , bytestring     , temporary     , directory     , logging-facade@@ -42,6 +43,7 @@       Test.Mockery.LoggingSpec   build-depends:       base == 4.*+    , bytestring     , temporary     , directory     , logging-facade
src/Test/Mockery/Directory.hs view
@@ -2,12 +2,16 @@   inTempDirectory , inTempDirectoryNamed , withFile+, touch ) where  import           Control.Exception+import           Control.Monad import           System.Directory+import           System.IO.Error import           System.IO hiding (withFile) import           System.IO.Temp (withSystemTempDirectory, withSystemTempFile)+import qualified Data.ByteString as B  -- | -- Run given action with the current working directory set to a temporary@@ -41,3 +45,11 @@   hPutStr h input   hClose h   action file++-- |+-- Update the modification time of the specified file.  Create an empty file if+-- the file does not exist.+touch :: FilePath -> IO ()+touch file = do+  c <- catchJust (guard . isDoesNotExistError) (B.readFile file) (const $ return B.empty)+  B.writeFile file c
src/Test/Mockery/Logging.hs view
@@ -2,6 +2,7 @@ module Test.Mockery.Logging (   captureLogMessages , captureLogMessages_+, LogLevel(..) ) where  import           Control.Applicative
test/Test/Mockery/DirectorySpec.hs view
@@ -1,13 +1,42 @@- module Test.Mockery.DirectorySpec where  import           Test.Hspec+import           System.Directory+import           System.Environment+import           Control.Concurrent+import           Data.Foldable  import           Test.Mockery.Directory +whenTravis :: IO () -> IO ()+whenTravis action = do+  env <- getEnvironment+  forM_ (lookup "TRAVIS" env) (const action)+ spec :: Spec spec = do   describe "withFile" $ do     it "creates a temporary file with the given contents" $ do       withFile "foo" $ \file ->         readFile file `shouldReturn` "foo"++  describe "touch" $ do+    around_ inTempDirectory $ do+      let name = "foo"+      it "creates an empty file" $ do+        touch name+        readFile name `shouldReturn` ""++      context "when file already exists" $ do+        before_ (writeFile name "bar") $ do+          it "updates modification time" $ do+            t0 <- getModificationTime name+            threadDelay 10000+            whenTravis (threadDelay 1000000)+            touch name+            t1 <- getModificationTime name+            t0 `shouldSatisfy` (< t1)++          it "does not modify file content" $ do+            touch name+            readFile name `shouldReturn` "bar"