remote-hg: add test to push new bookmark
[gitweb.git] / contrib / remote-helpers / test-hg.sh
index d244e236f6eca721f69e7f6345f6cf2f1a3f30df..8d70f4aefced6ce6dcc3eb7827923dbeba100427 100755 (executable)
@@ -32,6 +32,12 @@ check_branch () {
        test_cmp expected actual
 }
 
+check_bookmark () {
+       echo $3 > expected &&
+       hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' > actual &&
+       test_cmp expected actual
+}
+
 setup () {
        (
        echo "[ui]"
@@ -108,7 +114,22 @@ test_expect_success 'update bookmark' '
        git push --quiet
        ) &&
 
-       hg -R hgrepo bookmarks | egrep "devel[   ]+3:"
+       check_bookmark hgrepo devel devel
+'
+
+test_expect_success 'new bookmark' '
+       test_when_finished "rm -rf gitrepo*" &&
+
+       (
+       git clone "hg::hgrepo" gitrepo &&
+       cd gitrepo &&
+       git checkout --quiet -b feature-b &&
+       echo feature-b > content &&
+       git commit -a -m feature-b &&
+       git push --quiet origin feature-b
+       ) &&
+
+       check_bookmark hgrepo feature-b feature-b
 '
 
 # cleanup previous stuff
@@ -244,4 +265,57 @@ test_expect_success 'remote push from master branch' '
        check_branch hgrepo default one
 '
 
+GIT_REMOTE_HG_TEST_REMOTE=1
+export GIT_REMOTE_HG_TEST_REMOTE
+
+test_expect_success 'remote cloning' '
+       test_when_finished "rm -rf gitrepo*" &&
+
+       (
+       hg init hgrepo &&
+       cd hgrepo &&
+       echo zero > content &&
+       hg add content &&
+       hg commit -m zero
+       ) &&
+
+       git clone "hg::hgrepo" gitrepo &&
+       check gitrepo HEAD zero
+'
+
+test_expect_success 'remote update bookmark' '
+       test_when_finished "rm -rf gitrepo*" &&
+
+       (
+       cd hgrepo &&
+       hg bookmark devel
+       ) &&
+
+       (
+       git clone "hg::hgrepo" gitrepo &&
+       cd gitrepo &&
+       git checkout --quiet devel &&
+       echo devel > content &&
+       git commit -a -m devel &&
+       git push --quiet
+       ) &&
+
+       check_bookmark hgrepo devel devel
+'
+
+test_expect_success 'remote new bookmark' '
+       test_when_finished "rm -rf gitrepo*" &&
+
+       (
+       git clone "hg::hgrepo" gitrepo &&
+       cd gitrepo &&
+       git checkout --quiet -b feature-b &&
+       echo feature-b > content &&
+       git commit -a -m feature-b &&
+       git push --quiet origin feature-b
+       ) &&
+
+       check_bookmark hgrepo feature-b feature-b
+'
+
 test_done