summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/fixtures/srht.ini8
-rw-r--r--tests/test_config.c35
2 files changed, 35 insertions, 8 deletions
diff --git a/tests/fixtures/srht.ini b/tests/fixtures/srht.ini
new file mode 100644
index 0000000..51c8ddb
--- /dev/null
+++ b/tests/fixtures/srht.ini
@@ -0,0 +1,8 @@
+[srht]
+endpoint = https://git.sr.ht/query
+token = ABC123XYZ
+user_agent = user-agent
+owner = my-org
+
+[git]
+base = /srv/git
diff --git a/tests/test_config.c b/tests/test_config.c
index 8d21d62..5e4aab1 100644
--- a/tests/test_config.c
+++ b/tests/test_config.c
@@ -28,19 +28,38 @@ static void config_read_normal(void **state)
assert_string_equal(cfg->git_base, "/srv/git");
assert_non_null(cfg->head);
- assert_string_equal(cfg->head->endpoint, "https://api.github.com/graphql");
- assert_string_equal(cfg->head->token, "ghp_1234567890abcdef");
- assert_string_equal(cfg->head->user_agent, "user-agent");
- assert_string_equal(cfg->head->owner, "my-org");
+ assert_int_equal(cfg->head->type, remote_type_github);
+ assert_string_equal(cfg->head->gh.endpoint,
+ "https://api.github.com/graphql");
+ assert_string_equal(cfg->head->gh.token, "ghp_1234567890abcdef");
+ assert_string_equal(cfg->head->gh.user_agent, "user-agent");
+ assert_string_equal(cfg->head->gh.owner, "my-org");
+ config_free(cfg);
+}
+
+static void config_read_srht(void **state)
+{
+ (void) state;
+ const char *path = "../tests/fixtures/srht.ini";
+ struct config *cfg = config_read(path);
+ assert_non_null(cfg);
+ assert_string_equal(cfg->git_base, "/srv/git");
+
+ assert_non_null(cfg->head);
+ assert_int_equal(cfg->head->type, remote_type_srht);
+ assert_string_equal(cfg->head->srht.endpoint,
+ "https://git.sr.ht/query");
+ assert_string_equal(cfg->head->srht.token, "ABC123XYZ");
+ assert_string_equal(cfg->head->srht.user_agent, "user-agent");
+ assert_string_equal(cfg->head->srht.owner, "my-org");
config_free(cfg);
}
int main(void)
{
- const struct CMUnitTest tests[] = {
- cmocka_unit_test(config_read_empty),
- cmocka_unit_test(config_read_normal)
- };
+ const struct CMUnitTest tests[] = {cmocka_unit_test(config_read_empty),
+ cmocka_unit_test(config_read_normal),
+ cmocka_unit_test(config_read_srht)};
return cmocka_run_group_tests(tests, NULL, NULL);
}