summaryrefslogtreecommitdiff
path: root/Test.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-25 13:51:36 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-25 13:51:36 -0400
commit9c1f5d93e4956c0ec5e5bf480ac7cbb090d20698 (patch)
treef0865a47e2973d015f6440a77697b5920af0d448 /Test.hs
parentbe7b9385cb74bdad1531241d3ada6b65ecf5ece3 (diff)
some basic tests of preferred content expressions and standard groups
Diffstat (limited to 'Test.hs')
-rw-r--r--Test.hs38
1 files changed, 37 insertions, 1 deletions
diff --git a/Test.hs b/Test.hs
index 2a0a0113a..047bcf0bb 100644
--- a/Test.hs
+++ b/Test.hs
@@ -57,6 +57,7 @@ import qualified Utility.InodeCache
import qualified Utility.Env
import qualified Utility.Gpg
import qualified Utility.Matcher
+import qualified Utility.Exception
#ifndef __WINDOWS__
import qualified GitAnnex
#endif
@@ -167,6 +168,7 @@ hunit =
, check "rsync remote" test_rsync_remote
, check "bup remote" test_bup_remote
, check "crypto" test_crypto
+ , check "preferred content" test_preferred_content
]
where
check desc t env = do
@@ -341,6 +343,40 @@ test_copy env = "git-annex copy" ~: TestCase $ intmpclonerepo env $ do
checkregularfile ingitfile
checkcontent ingitfile
+test_preferred_content :: TestEnv -> Test
+test_preferred_content env = "git-annex preferred-content" ~: TestCase $ intmpclonerepo env $ do
+ annexed_notpresent annexedfile
+ -- get --auto only looks at numcopies when preferred content is not
+ -- set, and with 1 copy existing, does not get the file.
+ git_annex env "get" ["--auto", annexedfile] @? "get --auto of file failed with default preferred content"
+ annexed_notpresent annexedfile
+
+ git_annex env "content" [".", "standard"] @? "set expression to standard failed"
+ git_annex env "group" [".", "client"] @? "set group to standard failed"
+ git_annex env "get" ["--auto", annexedfile] @? "get --auto of file failed for client"
+ annexed_present annexedfile
+ git_annex env "ungroup" [".", "client"] @? "ungroup failed"
+
+ git_annex env "content" [".", "standard"] @? "set expression to standard failed"
+ git_annex env "group" [".", "manual"] @? "set group to manual failed"
+ -- drop --auto with manual leaves the file where it is
+ git_annex env "drop" ["--auto", annexedfile] @? "drop --auto of file failed with manual preferred content"
+ annexed_present annexedfile
+ git_annex env "drop" [annexedfile] @? "drop of file failed"
+ annexed_notpresent annexedfile
+ -- get --auto with manual does not get the file
+ git_annex env "get" ["--auto", annexedfile] @? "get --auto of file failed with manual preferred content"
+ annexed_notpresent annexedfile
+ git_annex env "ungroup" [".", "client"] @? "ungroup failed"
+
+ git_annex env "content" [".", "exclude=*"] @? "set expression to exclude=* failed"
+ git_annex env "get" [annexedfile] @? "get of file failed"
+ annexed_present annexedfile
+ git_annex env "drop" ["--auto", annexedfile] @? "drop --auto of file failed with exclude=*"
+ annexed_notpresent annexedfile
+ git_annex env "get" ["--auto", annexedfile] @? "get --auto of file failed with exclude=*"
+ annexed_notpresent annexedfile
+
test_lock :: TestEnv -> Test
test_lock env = "git-annex unlock/lock" ~: intmpclonerepoInDirect env $ do
-- regression test: unlock of not present file should skip it
@@ -960,7 +996,7 @@ checkregularfile f = do
checkcontent :: FilePath -> Assertion
checkcontent f = do
- c <- readFile f
+ c <- Utility.Exception.catchDefaultIO "could not read file" $ readFile f
assertEqual ("checkcontent " ++ f) (content f) c
checkunwritable :: FilePath -> Assertion