Minor cleanup

This commit is contained in:
Gregor Kleen 2018-11-09 14:58:37 +01:00
parent c3fc8a218a
commit 7d132bf779

View File

@ -20,7 +20,7 @@ instance Arbitrary File where
arbitrary = do
fileTitle <- (joinPath <$> arbitrary) `suchThat` (any $ not . isPathSeparator)
date <- addDays <$> arbitrary <*> pure (fromGregorian 2043 7 2)
fileModified <- addUTCTime <$> arbitrary <*> pure (UTCTime date 0)
fileModified <- (addUTCTime <$> arbitrary <*> pure (UTCTime date 0)) `suchThat` inZipRange
fileContent <- arbitrary
return File{..}
shrink = genericShrink
@ -35,8 +35,7 @@ spec = describe "Zip file handling" $ do
= makeValid . dropWhile isPathSeparator . bool (dropWhileEnd isPathSeparator) addTrailingPathSeparator (isNothing $ fileContent file) . normalise . makeValid
acceptableTimeDifference t1 t2 = abs (diffUTCTime t1 t2) <= 2
(shouldBe `on` acceptableFilenameChanges) (fileTitle file') (fileTitle file)
when (inZipRange $ fileModified file) $
(fileModified file', fileModified file) `shouldSatisfy` uncurry acceptableTimeDifference
(fileModified file', fileModified file) `shouldSatisfy` uncurry acceptableTimeDifference
(fileContent file') `shouldBe` (fileContent file)
inZipRange :: UTCTime -> Bool