]>
git.proxmox.com Git - libgit2.git/blob - tests/config/readonly.c
5d544b8cb4a08bb9bea67ce4ff1893d58f30c169
1 #include "clar_libgit2.h"
2 #include "config_backend.h"
6 static git_config
*cfg
;
8 void test_config_readonly__initialize(void)
10 cl_git_pass(git_config_new(&cfg
));
13 void test_config_readonly__cleanup(void)
19 void test_config_readonly__writing_to_readonly_fails(void)
21 git_config_backend
*backend
;
23 cl_git_pass(git_config_backend_from_file(&backend
, "global"));
24 backend
->readonly
= 1;
25 cl_git_pass(git_config_add_backend(cfg
, backend
, GIT_CONFIG_LEVEL_GLOBAL
, NULL
, 0));
27 cl_git_fail_with(GIT_ENOTFOUND
, git_config_set_string(cfg
, "foo.bar", "baz"));
28 cl_assert(!git_path_exists("global"));
31 void test_config_readonly__writing_to_cfg_with_rw_precedence_succeeds(void)
33 git_config_backend
*backend
;
35 cl_git_pass(git_config_backend_from_file(&backend
, "global"));
36 backend
->readonly
= 1;
37 cl_git_pass(git_config_add_backend(cfg
, backend
, GIT_CONFIG_LEVEL_GLOBAL
, NULL
, 0));
39 cl_git_pass(git_config_backend_from_file(&backend
, "local"));
40 cl_git_pass(git_config_add_backend(cfg
, backend
, GIT_CONFIG_LEVEL_LOCAL
, NULL
, 0));
42 cl_git_pass(git_config_set_string(cfg
, "foo.bar", "baz"));
44 cl_assert(git_path_exists("local"));
45 cl_assert(!git_path_exists("global"));
46 cl_git_pass(p_unlink("local"));
49 void test_config_readonly__writing_to_cfg_with_ro_precedence_succeeds(void)
51 git_config_backend
*backend
;
53 cl_git_pass(git_config_backend_from_file(&backend
, "local"));
54 backend
->readonly
= 1;
55 cl_git_pass(git_config_add_backend(cfg
, backend
, GIT_CONFIG_LEVEL_LOCAL
, NULL
, 0));
57 cl_git_pass(git_config_backend_from_file(&backend
, "global"));
58 cl_git_pass(git_config_add_backend(cfg
, backend
, GIT_CONFIG_LEVEL_GLOBAL
, NULL
, 0));
60 cl_git_pass(git_config_set_string(cfg
, "foo.bar", "baz"));
62 cl_assert(!git_path_exists("local"));
63 cl_assert(git_path_exists("global"));
64 cl_git_pass(p_unlink("global"));