diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/blogc-git-receiver/check_pre_receive.sh.in | 10 | ||||
-rw-r--r-- | tests/blogc-git-receiver/check_pre_receive_parser.c | 48 |
2 files changed, 42 insertions, 16 deletions
diff --git a/tests/blogc-git-receiver/check_pre_receive.sh.in b/tests/blogc-git-receiver/check_pre_receive.sh.in index 9ac12df..2cf3c89 100755 --- a/tests/blogc-git-receiver/check_pre_receive.sh.in +++ b/tests/blogc-git-receiver/check_pre_receive.sh.in @@ -29,7 +29,7 @@ EOF cd "${TEMP}/repos/foo.git" SHELL="${SELF}" HOME="${TEMP}" GIT_DIR=. ${TESTS_ENVIRONMENT} ./hooks/pre-receive < "${TEMP}/payload.txt" 2>&1 | tee "${TEMP}/output.txt" -grep "warning: no reference to master branch found. nothing to deploy." "${TEMP}/output.txt" &> /dev/null +grep "warning: no suitable branch found. nothing to deploy." "${TEMP}/output.txt" &> /dev/null cat > "${TEMP}/tmp.txt" <<EOF blob @@ -55,7 +55,7 @@ git fast-import < "${TEMP}/tmp.txt" &> /dev/null cat > "${TEMP}/payload.txt" <<EOF 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 refs/heads/foo 0000000000000000000000000000000000000000 $(git rev-parse master) refs/heads/master -0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 refs/heads/bar +0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 refs/heads/main EOF SHELL="${SELF}" HOME="${TEMP}" GIT_DIR=. ${TESTS_ENVIRONMENT} ./hooks/pre-receive < "${TEMP}/payload.txt" 2>&1 | tee "${TEMP}/output.txt" @@ -73,8 +73,8 @@ all: mkdir -p \$(OUTPUT_DIR) echo lol > \$(OUTPUT_DIR)/foo.txt -reset refs/heads/master -commit refs/heads/master +reset refs/heads/main +commit refs/heads/main mark :2 author Rafael G. Martins <rafael@rafaelmartins.eng.br> 1476139736 +0200 committer Rafael G. Martins <rafael@rafaelmartins.eng.br> 1476139736 +0200 @@ -89,7 +89,7 @@ git fast-import < "${TEMP}/tmp.txt" &> /dev/null cat > "${TEMP}/payload.txt" <<EOF 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 refs/heads/foo -0000000000000000000000000000000000000000 $(git rev-parse master) refs/heads/master +0000000000000000000000000000000000000000 $(git rev-parse main) refs/heads/main 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 refs/heads/bar EOF diff --git a/tests/blogc-git-receiver/check_pre_receive_parser.c b/tests/blogc-git-receiver/check_pre_receive_parser.c index 0415be1..c431821 100644 --- a/tests/blogc-git-receiver/check_pre_receive_parser.c +++ b/tests/blogc-git-receiver/check_pre_receive_parser.c @@ -43,18 +43,28 @@ test_pre_receive_parse(void **state) "4f1f932f6ef6d6c9770266775c2db072964d7a62 " "3fff4bb3172f77b292b0c913749e81bedd3545f3 " "refs/heads/master")); - assert_null(_bgr_pre_receive_parse( + + bc_trie_t *t; + t = _bgr_pre_receive_parse( "4f1f932f6ef6d6c9770266775c2db072964d7a62 " "3fff4bb3172f77b292b0c913749e81bedd3545f3 " - "refs/heads/master asd\n")); - char *t; + "refs/heads/master asd\n"); + assert_non_null(t); + assert_int_equal(bc_trie_size(t), 1); + assert_string_equal(bc_trie_lookup(t, "master asd"), + "3fff4bb3172f77b292b0c913749e81bedd3545f3"); + bc_trie_free(t); + t = _bgr_pre_receive_parse( "4f1f932f6ef6d6c9770266775c2db072964d7a62 " "3fff4bb3172f77b292b0c913749e81bedd3545f3 " "refs/heads/master\n"); assert_non_null(t); - assert_string_equal(t, "3fff4bb3172f77b292b0c913749e81bedd3545f3"); - free(t); + assert_int_equal(bc_trie_size(t), 1); + assert_string_equal(bc_trie_lookup(t, "master"), + "3fff4bb3172f77b292b0c913749e81bedd3545f3"); + bc_trie_free(t); + t = _bgr_pre_receive_parse( "4f1f932f6ef6d6c9770266775c2db072964d7a62 " "3fff4bb3172f77b292b0c913749e81bedd3545fa " @@ -64,8 +74,13 @@ test_pre_receive_parse(void **state) "refs/heads/bola\n" ); assert_non_null(t); - assert_string_equal(t, "3fff4bb3172f77b292b0c913749e81bedd3545fa"); - free(t); + assert_int_equal(bc_trie_size(t), 2); + assert_string_equal(bc_trie_lookup(t, "master"), + "3fff4bb3172f77b292b0c913749e81bedd3545fa"); + assert_string_equal(bc_trie_lookup(t, "bola"), + "3fff4bb3172f77b292b0c913749e81bedd3545f4"); + bc_trie_free(t); + t = _bgr_pre_receive_parse( "4f1f932f6ef6d6c9770266775c2db072964d7a63 " "3fff4bb3172f77b292b0c913749e81bedd3545f4 " @@ -75,8 +90,13 @@ test_pre_receive_parse(void **state) "refs/heads/master\n" ); assert_non_null(t); - assert_string_equal(t, "3fff4bb3172f77b292b0c913749e81bedd3545fb"); - free(t); + assert_int_equal(bc_trie_size(t), 2); + assert_string_equal(bc_trie_lookup(t, "bola"), + "3fff4bb3172f77b292b0c913749e81bedd3545f4"); + assert_string_equal(bc_trie_lookup(t, "master"), + "3fff4bb3172f77b292b0c913749e81bedd3545fb"); + bc_trie_free(t); + t = _bgr_pre_receive_parse( "4f1f932f6ef6d6c9770266775c2db072964d7a63 " "3fff4bb3172f77b292b0c913749e81bedd3545f4 " @@ -89,8 +109,14 @@ test_pre_receive_parse(void **state) "refs/heads/bolao\n" ); assert_non_null(t); - assert_string_equal(t, "3fff4bb3172f77b292b0c913749e81bedd3545fc"); - free(t); + assert_int_equal(bc_trie_size(t), 3); + assert_string_equal(bc_trie_lookup(t, "bola"), + "3fff4bb3172f77b292b0c913749e81bedd3545f4"); + assert_string_equal(bc_trie_lookup(t, "master"), + "3fff4bb3172f77b292b0c913749e81bedd3545fc"); + assert_string_equal(bc_trie_lookup(t, "bolao"), + "3fff4bb3172f77b292b0c913749e81bedd3545f5"); + bc_trie_free(t); } |