From 3cd3dcb5bb3b0481812ddd3ff8dc182bdb20be23 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Mon, 10 Oct 2016 02:13:47 +0200 Subject: git-receiver: added support to get mirror url from config file this commit also includes some "integration test" in shell script --- tests/blogc-git-receiver/check_post_receive.sh | 87 ++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 tests/blogc-git-receiver/check_post_receive.sh (limited to 'tests/blogc-git-receiver/check_post_receive.sh') diff --git a/tests/blogc-git-receiver/check_post_receive.sh b/tests/blogc-git-receiver/check_post_receive.sh new file mode 100755 index 0000000..78b566e --- /dev/null +++ b/tests/blogc-git-receiver/check_post_receive.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +set -xe -o pipefail + +TEMP="$(mktemp -d)" +[[ -n "${TEMP}" ]] + +trap_func() { + [[ -e "${TEMP}/output.txt" ]] && cat "${TEMP}/output.txt" + rm -rf "${TEMP}" +} + +trap trap_func EXIT + +mkdir -p "${TEMP}/repos" +git init --bare "${TEMP}/repos/foo.git" &> /dev/null + +ln -s "${PWD}/blogc-git-receiver" "${TEMP}/repos/foo.git/hooks/post-receive" + +cat > "${TEMP}/tmp.txt" < 1476033730 +0200 +committer Rafael G. Martins 1476033888 +0200 +data 11 +testing... +M 100644 :1 foo + +EOF + +cd "${TEMP}/repos/foo.git" +git fast-import < "${TEMP}/tmp.txt" &> /dev/null + +git init --bare "${TEMP}/repos/bar.git" &> /dev/null + +HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./hooks/post-receive 2>&1 | tee "${TEMP}/output.txt" +grep "warning: repository mirroring disabled" "${TEMP}/output.txt" &> /dev/null + +git config --local remote.mirror.pushurl "${TEMP}/repos/bar.git" +HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./hooks/post-receive 2>&1 | tee "${TEMP}/output.txt" +grep "[new branch] *master" "${TEMP}/output.txt" &> /dev/null + +git config --local --unset remote.mirror.pushurl +rm -rf "${TEMP}/repos/bar.git" +git init --bare "${TEMP}/repos/bar.git" &> /dev/null +git config --local remote.mirror.url "${TEMP}/repos/bar.git" +HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./hooks/post-receive 2>&1 | tee "${TEMP}/output.txt" +grep "[new branch] *master" "${TEMP}/output.txt" &> /dev/null + +git config --local --unset remote.mirror.url +rm -rf "${TEMP}/repos/bar.git" +cat > "${TEMP}/blogc-git-receiver.ini" < /dev/null +HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./hooks/post-receive 2>&1 | tee "${TEMP}/output.txt" +grep "[new branch] *master" "${TEMP}/output.txt" &> /dev/null + +rm -rf "${TEMP}/repos/bar.git" +cat > "${TEMP}/blogc-git-receiver.ini" < /dev/null +HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./hooks/post-receive 2>&1 | tee "${TEMP}/output.txt" +grep "warning: failed to parse configuration file " "${TEMP}/output.txt" &> /dev/null + +rm "${TEMP}/output.txt" -- cgit v1.2.3-18-g5258