aboutsummaryrefslogtreecommitdiffstats
path: root/tests/blogc-git-receiver/check_post_receive.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2018-05-30 23:53:26 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2018-05-30 23:53:26 +0200
commit316bd60579ea11daca4fa25e2720b7fa147cc7ba (patch)
treeaa53a0daefe10e4d4f58f04af483db5094611a65 /tests/blogc-git-receiver/check_post_receive.c
parent9acec235a6c47c3bede917187808a8acd1369050 (diff)
downloadblogc-316bd60579ea11daca4fa25e2720b7fa147cc7ba.tar.gz
blogc-316bd60579ea11daca4fa25e2720b7fa147cc7ba.tar.bz2
blogc-316bd60579ea11daca4fa25e2720b7fa147cc7ba.zip
git-receiver: centralize settings to reuse later
Diffstat (limited to 'tests/blogc-git-receiver/check_post_receive.c')
-rw-r--r--tests/blogc-git-receiver/check_post_receive.c91
1 files changed, 0 insertions, 91 deletions
diff --git a/tests/blogc-git-receiver/check_post_receive.c b/tests/blogc-git-receiver/check_post_receive.c
deleted file mode 100644
index 5d2d742..0000000
--- a/tests/blogc-git-receiver/check_post_receive.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * blogc: A blog compiler.
- * Copyright (C) 2014-2017 Rafael G. Martins <rafael@rafaelmartins.eng.br>
- *
- * This program can be distributed under the terms of the BSD License.
- * See the file LICENSE.
- */
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-#include <string.h>
-#include <stdlib.h>
-#include "../../src/common/config-parser.h"
-#include "../../src/common/utils.h"
-#include "../../src/blogc-git-receiver/post-receive.h"
-
-
-char*
-__wrap_realpath(const char *path, char *resolved_path)
-{
- const char *real_path = mock_type(const char*);
- if (real_path == NULL)
- return NULL;
- assert_string_equal(path, real_path);
- return bc_strdup(real_path);
-}
-
-
-static void
-test_post_receive_get_config_section(void **state)
-{
- bc_error_t *err = NULL;
-
- bc_config_t *config = bc_config_parse("", 0, NULL, &err);
- assert_null(err);
- assert_null(bgr_post_receive_get_config_section(config,
- "/home/blogc/repos/foo.git", "/home/blogc"));
- bc_config_free(config);
-
- will_return(__wrap_realpath, NULL);
- will_return(__wrap_realpath, "/home/blogc/repos/bar.git");
- const char *conf =
- "[repo:foo.git]\n"
- "mirror = foo\n"
- "\n"
- "[repo:bar.git]\n"
- "mirror = bar\n"
- "\n"
- "[repo:baz.git]\n"
- "mirror = baz\n"
- "\n";
- config = bc_config_parse(conf, strlen(conf), NULL, &err);
- assert_null(err);
- char *s = bgr_post_receive_get_config_section(config,
- "/home/blogc/repos/bar.git", "/home/blogc");
- assert_string_equal(s, "repo:bar.git");
- free(s);
- bc_config_free(config);
-
- will_return(__wrap_realpath, NULL);
- will_return(__wrap_realpath, "/home/blogc/repos/asd/bar.git");
- conf =
- "[repo:asd/foo.git]\n"
- "mirror = foo\n"
- "\n"
- "[repo:asd/bar.git]\n"
- "mirror = bar\n"
- "\n"
- "[repo:asd/baz.git]\n"
- "mirror = baz\n"
- "\n";
- config = bc_config_parse(conf, strlen(conf), NULL, &err);
- assert_null(err);
- s = bgr_post_receive_get_config_section(config,
- "/home/blogc/repos/asd/bar.git", "/home/blogc");
- assert_string_equal(s, "repo:asd/bar.git");
- free(s);
- bc_config_free(config);
-}
-
-
-int
-main(void)
-{
- const UnitTest tests[] = {
- unit_test(test_post_receive_get_config_section),
- };
- return run_tests(tests);
-}