aboutsummaryrefslogtreecommitdiff
path: root/test.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-01-26 16:20:28 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-01-26 16:20:28 -0400
commit7f6af79232eee685daf58e72737c5284f80cf482 (patch)
treee3ec0e7612845e056df355c6841ee9a58e603d52 /test.hs
parent7b2da21ab7bc51785203a69cc05ab811a8629ecb (diff)
trust setting improvements
Diffstat (limited to 'test.hs')
-rw-r--r--test.hs64
1 files changed, 35 insertions, 29 deletions
diff --git a/test.hs b/test.hs
index c5e755966..817b1bafb 100644
--- a/test.hs
+++ b/test.hs
@@ -42,7 +42,7 @@ import qualified Command.DropUnused
main :: IO ()
main = do
prepare
- r <- runVerboseTests $ TestList [quickchecks, toplevels]
+ r <- runVerboseTests $ TestList [quickcheck, blackbox]
cleanup tmpdir
propigate r
@@ -51,8 +51,8 @@ propigate (Counts { errors = e }, _)
| e > 0 = error "failed"
| otherwise = return ()
-quickchecks :: Test
-quickchecks = TestLabel "quickchecks" $ TestList
+quickcheck :: Test
+quickcheck = TestLabel "quickcheck" $ TestList
[ qctest "prop_idempotent_deencode" Git.prop_idempotent_deencode
, qctest "prop_idempotent_fileKey" Locations.prop_idempotent_fileKey
, qctest "prop_idempotent_key_read_show" BackendTypes.prop_idempotent_key_read_show
@@ -62,8 +62,8 @@ quickchecks = TestLabel "quickchecks" $ TestList
, qctest "prop_relPathDirToDir_basics" Utility.prop_relPathDirToDir_basics
]
-toplevels :: Test
-toplevels = TestLabel "toplevel" $ TestList
+blackbox :: Test
+blackbox = TestLabel "blackbox" $ TestList
-- test order matters, later tests may rely on state from earlier
[ test_init
, test_add
@@ -290,38 +290,44 @@ test_fix = "git-annex fix" ~: intmpclonerepo $ do
test_trust :: Test
test_trust = "git-annex trust/untrust/semitrust" ~: intmpclonerepo $ do
- trustcheck Trust.SemiTrusted
- git_annex "trust" ["-q", "origin"] @? "trust failed"
- trustcheck Trust.Trusted
- git_annex "trust" ["-q", "origin"] @? "trust of trusted failed"
- trustcheck Trust.Trusted
- git_annex "untrust" ["-q", "origin"] @? "untrust failed"
- trustcheck Trust.UnTrusted
- git_annex "untrust" ["-q", "origin"] @? "untrust of untrusted failed"
- trustcheck Trust.UnTrusted
- git_annex "semitrust" ["-q", "origin"] @? "semitrust failed"
- trustcheck Trust.SemiTrusted
- git_annex "semitrust" ["-q", "origin"] @? "semitrust of semitrusted failed"
- trustcheck Trust.SemiTrusted
+ git_annex "trust" ["-q", repo] @? "trust failed"
+ trustcheck Trust.Trusted "trusted 1"
+ git_annex "trust" ["-q", repo] @? "trust of trusted failed"
+ trustcheck Trust.Trusted "trusted 2"
+ git_annex "untrust" ["-q", repo] @? "untrust failed"
+ trustcheck Trust.UnTrusted "untrusted 1"
+ git_annex "untrust" ["-q", repo] @? "untrust of untrusted failed"
+ trustcheck Trust.UnTrusted "untrusted 2"
+ git_annex "semitrust" ["-q", repo] @? "semitrust failed"
+ trustcheck Trust.SemiTrusted "semitrusted 1"
+ git_annex "semitrust" ["-q", repo] @? "semitrust of semitrusted failed"
+ trustcheck Trust.SemiTrusted "semitrusted 2"
where
- trustcheck expected = do
+ trustcheck expected msg = do
present <- annexeval $ do
+ Remotes.readConfigs
l <- Trust.trustGet expected
- r <- Remotes.byName "origin"
+ r <- Remotes.byName repo
u <- UUID.getUUID r
return $ elem u l
- assertEqual ("trust value " ++ show expected) True present
+ assertBool msg present
+ repo = "origin"
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"
- corrupt annexedfile
- corrupt sha1annexedfile
+test_fsck = "git-annex fsck" ~: TestList [basicfsck, withlocaluntrusted]
where
+ basicfsck = TestCase $ 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"
+ corrupt annexedfile
+ corrupt sha1annexedfile
+ withlocaluntrusted = TestCase $ intmpcopyrepo $ do
+ git_annex "untrust" ["-q", "."] @? "untrust of current repo failed"
+ r <- git_annex "fsck" ["-q"]
+ not r @? "fsck failed to fail with content only available in untrusted (current) repository"
corrupt f = do
git_annex "get" ["-q", f] @? "get of file failed"
Content.allowWrite f