]> git.droids-corp.org - git-central.git/commitdiff
Test using the pre-receive -> pre-receive-ticket shim.
authorStephen Haberman <stephen@exigencecorp.com>
Fri, 20 Jun 2008 01:29:58 +0000 (20:29 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Fri, 20 Jun 2008 01:29:58 +0000 (20:29 -0500)
server/pre-receive [new file with mode: 0644]
tests/t2000-server-pre-receive-ticket.sh
tests/t2001-server-pre-receive-ticket-via-shim.sh [new file with mode: 0644]

diff --git a/server/pre-receive b/server/pre-receive
new file mode 100644 (file)
index 0000000..25f6c23
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+. $GIT_DIR/hooks/pre-receive-ticket
+
index b84dca5ba73c9a6bfd785ba095de542805f3bb55..7c5c5d303763285d94ff95b87f6d49d7c8b5e191 100644 (file)
@@ -21,16 +21,16 @@ install_server_hook 'pre-receive-ticket' 'pre-receive'
 
 test_expect_success 'reject with bad message' '
        echo $test_name >a &&
-       git commit -a -m "foo" &&
-       git push >push.out 2>push.err
+       git commit -a -m "$test_name" &&
        head=$(git rev-parse HEAD)
+       git push >push.out 2>push.err
        cat push.err | grep "Commit $head does not reference a ticket"
 '
 
 # the last test has a dirty commit message, so ammend it with a good message
 test_expect_success 'accept with re' '
        echo $test_name >a &&
-       git commit --amend -m "foo re #3222" &&
+       git commit --amend -m "$test_name re #3222" &&
        git push
 '
 
diff --git a/tests/t2001-server-pre-receive-ticket-via-shim.sh b/tests/t2001-server-pre-receive-ticket-via-shim.sh
new file mode 100644 (file)
index 0000000..6a99ba6
--- /dev/null
@@ -0,0 +1,39 @@
+
+#!/bin/sh
+
+test_description='server pre-receive ticket enforcer via shim'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+       echo This is a test. >a &&
+       git add a &&
+       git commit -m "a" &&
+       git clone ./. server &&
+       rm -fr server/.git/hooks &&
+       git remote add origin ./server &&
+       git config --add branch.master.remote origin &&
+       git config --add branch.master.merge refs/heads/master
+'
+
+# setup the shim
+install_server_hook 'pre-receive' 'pre-receive'
+install_server_hook 'pre-receive-ticket' 'pre-receive-ticket'
+
+test_expect_success 'reject with bad message via shim' '
+       echo $test_name >a &&
+       git commit -a -m "$test_name" &&
+       head=$(git rev-parse HEAD)
+       git push >push.out 2>push.err
+       cat push.err | grep "Commit $head does not reference a ticket"
+'
+
+# the last test has a dirty commit message, so ammend it with a good message
+test_expect_success 'accept with re via shim' '
+       echo $test_name >a &&
+       git commit --amend -m "$test_name re #3222" &&
+       git push
+'
+
+test_done
+