diff options
author | 2025-04-09 13:24:53 -0700 | |
---|---|---|
committer | 2025-04-11 00:15:18 -0700 | |
commit | f277f41d83d450a1f28d350bb7d6da075d1d2741 (patch) | |
tree | e197a7de7e26b47cec57a46acdde4b6c74889ad5 /tests/test_config.c | |
download | github-mirror-f277f41d83d450a1f28d350bb7d6da075d1d2741.tar.gz github-mirror-f277f41d83d450a1f28d350bb7d6da075d1d2741.tar.zst github-mirror-f277f41d83d450a1f28d350bb7d6da075d1d2741.zip |
Initial Commit
Add cmake github workflow
Install dependencies in gh action
Fix missing directory
Fix compiler errors
Fix group name to gid conversion
Force cjson to statically link
Add header guards to query headers
Add install and cpack to CMakeLists.txt
Add config search and CLI arg parsing
Improve docs for git.c
Fix program continuing on -h flag
Diffstat (limited to 'tests/test_config.c')
-rw-r--r-- | tests/test_config.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_config.c b/tests/test_config.c new file mode 100644 index 0000000..41cacb1 --- /dev/null +++ b/tests/test_config.c @@ -0,0 +1,45 @@ +// +// Created by Anshul Gupta on 4/9/25. +// + +#include <stdarg.h> +#include <stddef.h> +#include <setjmp.h> +#include <stdint.h> +#include <cmocka.h> +#include <string.h> + +#include "../src/config.h" + +static void config_read_empty(void **state) +{ + (void) state; + const char *path = "../tests/fixtures/empty.ini"; + struct config *cfg = config_read(path); + assert_null(cfg); +} + +static void config_read_normal(void **state) +{ + (void) state; + const char *path = "../tests/fixtures/normal.ini"; + struct config *cfg = config_read(path); + assert_non_null(cfg); + assert_string_equal(cfg->endpoint, "https://api.github.com/graphql"); + assert_string_equal(cfg->token, "token"); + assert_string_equal(cfg->user_agent, "user-agent"); + assert_string_equal(cfg->owner, "my-org"); + assert_string_equal(cfg->git_base, "/srv/git"); + assert_int_equal(cfg->git_owner, 1000); + assert_int_equal(cfg->git_group, 1001); +} + +int main(void) +{ + const struct CMUnitTest tests[] = { + cmocka_unit_test(config_read_empty), + cmocka_unit_test(config_read_normal) + }; + + return cmocka_run_group_tests(tests, NULL, NULL); +} |