test fsck

This commit is contained in:
Joey Hess 2011-01-11 19:34:28 -04:00
parent cebee37401
commit cc7db6f058

16
test.hs
View file

@ -30,6 +30,7 @@ import qualified GitAnnex
import qualified LocationLog
import qualified UUID
import qualified Remotes
import qualified Core
main :: IO ()
main = do
@ -68,6 +69,7 @@ toplevels = TestLabel "toplevel" $ TestList
, test_edit
, test_fix
, test_trust
, test_fsck
]
test_init :: Test
@ -268,6 +270,20 @@ test_trust = "git-annex trust/untrust" ~: intmpclonerepo $ do
return $ elem u uuids
assertEqual "trust value" expected istrusted
test_fsck :: Test
test_fsck = "git-annex fsck" ~: intmpclonerepo $ do
git_annex "fsck" ["-q"] @? "fsck failed"
Utility.boolSystem "git" ["config", "annex.numcopies", "2"] @? "git config failed"
r <- git_annex "fsck" ["-q"]
not r @? "fsck failed to fail with numcopies unsatisfied"
Utility.boolSystem "git" ["config", "annex.numcopies", "1"] @? "git config failed"
git_annex "get" ["-q", annexedfile] @? "get of file failed"
Core.allowWrite annexedfile
writeFile annexedfile (changedcontent annexedfile)
r <- git_annex "fsck" ["-q"]
not r @? "fsck failed to fail with corrupted file content"
-- This is equivilant to running git-annex, but it's all run in-process
-- so test coverage collection works.
git_annex :: String -> [String] -> IO Bool