packages feed

hedgehog-extras 0.4.1.0 → 0.4.2.0

raw patch · 3 files changed

+22/−12 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Hedgehog.Extras.Test.Network: assertFileExists :: (MonadTest m, MonadIO m, HasCallStack) => FilePath -> m ()
+ Hedgehog.Extras.Test.File: assertFileExists :: (MonadTest m, MonadIO m, HasCallStack) => FilePath -> m ()
+ Hedgehog.Extras.Test.File: assertFileMissing :: (MonadTest m, MonadIO m, HasCallStack) => FilePath -> m ()
+ Hedgehog.Extras.Test.File: assertFilesMissing :: (MonadTest m, MonadIO m, HasCallStack) => [FilePath] -> m ()

Files

hedgehog-extras.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4  name:                   hedgehog-extras-version:                0.4.1.0+version:                0.4.2.0 synopsis:               Supplemental library for hedgehog description:            Supplemental library for hedgehog. category:               Test
src/Hedgehog/Extras/Test/File.hs view
@@ -37,7 +37,10 @@   , assertIsJsonFile   , assertIsYamlFile +  , assertFileExists   , assertFilesExist+  , assertFileMissing+  , assertFilesMissing   , assertFileOccurences   , assertFileLines   , assertEndsWithSingleNewline@@ -68,6 +71,7 @@  import qualified Data.Aeson as J import qualified Data.ByteString.Lazy as LBS+import           Data.Foldable (for_) import qualified Data.List as L import qualified Data.Text.IO as T import qualified Data.Time.Clock as DTC@@ -273,14 +277,25 @@     Right _ -> return ()     Left msg -> H.failMessage GHC.callStack msg --- | Checks if all files gives exists. If this fails, all files are deleted.+-- | Asserts that the given file exists.+assertFileExists :: (MonadTest m, MonadIO m, HasCallStack) => FilePath -> m ()+assertFileExists file = GHC.withFrozenCallStack $ do+  exists <- H.evalIO $ IO.doesFileExist file+  unless exists $ H.failWithCustom GHC.callStack Nothing (file <> " has not been successfully created.")++-- | Asserts that all of the given files exist. assertFilesExist :: (MonadTest m, MonadIO m, HasCallStack) => [FilePath] -> m ()-assertFilesExist [] = return ()-assertFilesExist (file:rest) = do+assertFilesExist files = GHC.withFrozenCallStack $ for_ files assertFileExists++-- | Asserts that the given file is missing.+assertFileMissing :: (MonadTest m, MonadIO m, HasCallStack) => FilePath -> m ()+assertFileMissing file = GHC.withFrozenCallStack $ do   exists <- H.evalIO $ IO.doesFileExist file-  if exists-    then GHC.withFrozenCallStack $ assertFilesExist rest-    else H.failWithCustom GHC.callStack Nothing (file <> " has not been successfully created.")+  when exists $ H.failWithCustom GHC.callStack Nothing (file <> " should not have been created.")++-- | Asserts that all of the given files are missing.+assertFilesMissing :: (MonadTest m, MonadIO m, HasCallStack) => [FilePath] -> m ()+assertFilesMissing files = GHC.withFrozenCallStack $ for_ files assertFileMissing  -- | Assert the file contains the given number of occurrences of the given string assertFileOccurences :: (MonadTest m, MonadIO m, HasCallStack) => Int -> String -> FilePath -> m ()
src/Hedgehog/Extras/Test/Network.hs view
@@ -4,7 +4,6 @@   ( doesFileExists   , isPortOpen   , doesSocketExist-  , assertFileExists   , assertPortOpen   , assertSocketExists   , doesSprocketExist@@ -45,10 +44,6 @@ -- | Test if a socket file exists doesSocketExist :: (MonadTest m, MonadIO m, HasCallStack) => FilePath -> m Bool doesSocketExist = GHC.withFrozenCallStack . H.evalIO . IO.doesSocketExist---- | Assert that a file exists-assertFileExists :: (MonadTest m, MonadIO m, HasCallStack) => FilePath -> m ()-assertFileExists = GHC.withFrozenCallStack . H.assertM . doesFileExists  -- | Assert that a port is open assertPortOpen :: (MonadTest m, MonadIO m, HasCallStack) => Int -> m ()