summaryrefslogtreecommitdiff
path: root/test.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-20 23:20:36 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-20 23:24:06 -0400
commit82a145df91ca93a55020172076297e79ff6c52e5 (patch)
tree26abd7d16035930ca0dacb6d38b0f0304ca6bf1d /test.hs
parentc11cfea35555ae3bab429c283d8c7571d285d4b1 (diff)
test encrypted special remote
This involved adding a test harness to run gpg with a dummy key, and lots of fun.
Diffstat (limited to 'test.hs')
-rw-r--r--test.hs29
1 files changed, 29 insertions, 0 deletions
diff --git a/test.hs b/test.hs
index 9ba0e5dd9..7c4744388 100644
--- a/test.hs
+++ b/test.hs
@@ -42,6 +42,8 @@ import qualified Config
import qualified Crypto
import qualified Utility.Path
import qualified Utility.FileMode
+import qualified Utility.Gpg
+import qualified Build.SysConfig
-- for quickcheck
instance Arbitrary Types.Key.Key where
@@ -116,6 +118,7 @@ blackbox = TestLabel "blackbox" $ TestList
, test_hook_remote
, test_directory_remote
, test_rsync_remote
+ , test_crypto
]
test_init :: Test
@@ -623,6 +626,32 @@ test_rsync_remote = "git-annex rsync remote" ~: intmpclonerepo $ do
not <$> git_annex "drop" [annexedfile, "--numcopies=2"] @? "drop failed to fail"
annexed_present annexedfile
+test_crypto :: Test
+test_crypto = "git-annex crypto" ~: intmpclonerepo $
+ -- gpg is not a build dependency, so only test when it's available
+ when Build.SysConfig.gpg $ do
+ Utility.Gpg.testTestHarness @? "test harness self-test failed"
+ Utility.Gpg.testHarness $ do
+ createDirectory "dir"
+ let initremote = git_annex "initremote"
+ [ "foo"
+ , "type=directory"
+ , "encryption=" ++ Utility.Gpg.testKeyId
+ , "directory=dir"
+ ]
+ initremote @? "initremote failed"
+ initremote @? "initremote failed when run twice in a row"
+ git_annex "get" [annexedfile] @? "get of file failed"
+ annexed_present annexedfile
+ git_annex "copy" [annexedfile, "--to", "foo"] @? "copy --to encrypted remote failed"
+ annexed_present annexedfile
+ git_annex "drop" [annexedfile, "--numcopies=2"] @? "drop failed"
+ annexed_notpresent annexedfile
+ git_annex "move" [annexedfile, "--from", "foo"] @? "move --from encrypted remote failed"
+ annexed_present annexedfile
+ not <$> git_annex "drop" [annexedfile, "--numcopies=2"] @? "drop failed to fail"
+ annexed_present annexedfile
+
-- 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