From 5c105a8540b5b91c3c7a05fa1814c5f14dc8540c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 3 Sep 2021 12:40:23 -0400 Subject: [PATCH] test borg special remote Sponsored-by: Boyd Stephen Smith Jr. on Patreon --- Build/Configure.hs | 1 + Test.hs | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Build/Configure.hs b/Build/Configure.hs index 83ef161ced..02e33ebf2a 100644 --- a/Build/Configure.hs +++ b/Build/Configure.hs @@ -30,6 +30,7 @@ tests = , TestCase "rsync" $ testCmd "rsync" "rsync --version >/dev/null" , TestCase "curl" $ testCmd "curl" "curl --version >/dev/null" , TestCase "bup" $ testCmd "bup" "bup --version >/dev/null" + , TestCase "borg" $ testCmd "borg" "borg --version >/dev/null" , TestCase "nice" $ testCmd "nice" "nice true >/dev/null" , TestCase "ionice" $ testCmd "ionice" "ionice -c3 true >/dev/null" , TestCase "nocache" $ testCmd "nocache" "nocache true >/dev/null" diff --git a/Test.hs b/Test.hs index ac78a6b2eb..eb2f7e397e 100644 --- a/Test.hs +++ b/Test.hs @@ -378,6 +378,7 @@ unitTests note = testGroup ("Unit Tests " ++ note) , testCase "directory remote" test_directory_remote , testCase "rsync remote" test_rsync_remote , testCase "bup remote" test_bup_remote + , testCase "borg remote" test_borg_remote , testCase "crypto" test_crypto , testCase "preferred content" test_preferred_content , testCase "required_content" test_required_content @@ -1784,6 +1785,33 @@ test_bup_remote = intmpclonerepo $ when BuildInfo.bup $ do git_annex "move" [annexedfile, "--from", "foo"] "move --from bup remote" annexed_present annexedfile +test_borg_remote :: Assertion +test_borg_remote = when BuildInfo.borg $ do + borgdirparent <- fromRawFilePath <$> (absPath . toRawFilePath =<< tmprepodir) + let borgdir = borgdirparent "borgrepo" + intmpclonerepo $ do + testProcess "borg" ["init", borgdir, "-e", "none"] (== True) "borg init" + testProcess "borg" ["create", borgdir++"::backup1", "."] (== True) "borg create" + + git_annex "initremote" (words $ "borg type=borg borgrepo="++borgdir) "initremote" + git_annex "sync" ["borg"] "sync borg" + git_annex_expectoutput "find" ["--in=borg"] [] + + git_annex "get" [annexedfile] "get of file" + annexed_present annexedfile + git_annex_expectoutput "find" ["--in=borg"] [] + + testProcess "borg" ["create", borgdir++"::backup2", "."] (== True) "borg create" + git_annex "sync" ["borg"] "sync borg after getting file" + git_annex_expectoutput "find" ["--in=borg"] [annexedfile] + + git "remote" ["rm", "origin"] "remote rm" + git_annex_shouldfail "drop" [annexedfile] + "drop from borg succeeded, but it should be untrusted by default" + git_annex "enableremote" ["borg", "appendonly=yes"] "enableremote appendonly" + git_annex "drop" [annexedfile] "drop from borg (appendonly)" + git_annex "get" [annexedfile, "--from=borg"] "get from borg" + -- gpg is not a build dependency, so only test when it's available test_crypto :: Assertion #ifndef mingw32_HOST_OS