]> git.proxmox.com Git - libgit2.git/blob - tests/config/new.c
baca05332239378d8e487de4f0a8bcf4dec7f6fc
[libgit2.git] / tests / config / new.c
1 #include "clar_libgit2.h"
2
3 #include "filebuf.h"
4 #include "futils.h"
5 #include "posix.h"
6
7 #define TEST_CONFIG "git-new-config"
8
9 void test_config_new__write_new_config(void)
10 {
11 git_config *config;
12 git_buf buf = GIT_BUF_INIT;
13
14 cl_git_mkfile(TEST_CONFIG, "");
15 cl_git_pass(git_config_open_ondisk(&config, TEST_CONFIG));
16
17 cl_git_pass(git_config_set_string(config, "color.ui", "auto"));
18 cl_git_pass(git_config_set_string(config, "core.editor", "ed"));
19
20 git_config_free(config);
21
22 cl_git_pass(git_config_open_ondisk(&config, TEST_CONFIG));
23
24 cl_git_pass(git_config_get_string_buf(&buf, config, "color.ui"));
25 cl_assert_equal_s("auto", buf.ptr);
26 git_buf_dispose(&buf);
27 cl_git_pass(git_config_get_string_buf(&buf, config, "core.editor"));
28 cl_assert_equal_s("ed", buf.ptr);
29
30 git_buf_dispose(&buf);
31 git_config_free(config);
32
33 cl_must_pass(p_unlink(TEST_CONFIG));
34 }