Skip to content

Commit

Permalink
Add test to ensure a directory doesn't exist (assertDirectoryMissing)
Browse files Browse the repository at this point in the history
  • Loading branch information
palas authored Mar 13, 2024
1 parent 56cb839 commit a94023e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Hedgehog/Extras/Test/File.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module Hedgehog.Extras.Test.File
, assertEndsWithSingleNewline

, appendFileTimeDelta
, assertDirectoryMissing
) where

import Control.Applicative (Applicative (..))
Expand Down Expand Up @@ -336,3 +337,9 @@ appendFileTimeDelta filePath offsetTime = GHC.withFrozenCallStack $ do
baseTime <- H.noteShowIO DTC.getCurrentTime
let delay = DTC.diffUTCTime baseTime offsetTime
appendFile filePath $ show @DTC.NominalDiffTime delay <> "\n"

-- | Asserts that the given directory is missing.
assertDirectoryMissing :: (MonadTest m, MonadIO m, HasCallStack) => FilePath -> m ()
assertDirectoryMissing dir = GHC.withFrozenCallStack $ do
exists <- H.evalIO $ IO.doesDirectoryExist dir
when exists $ H.failWithCustom GHC.callStack Nothing (dir <> " should not have been created.")

0 comments on commit a94023e

Please sign in to comment.