Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
2a7086fa
Commit
2a7086fa
authored
Apr 25, 2017
by
Patrick Steinhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: config: verify functionality with read-only backends
parent
95f29fb3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
tests/config/readonly.c
+64
-0
No files found.
tests/config/readonly.c
0 → 100644
View file @
2a7086fa
#include "clar_libgit2.h"
#include "config_file.h"
#include "config.h"
static
git_config
*
cfg
;
void
test_config_readonly__initialize
(
void
)
{
cl_git_pass
(
git_config_new
(
&
cfg
));
}
void
test_config_readonly__cleanup
(
void
)
{
git_config_free
(
cfg
);
cfg
=
NULL
;
}
void
test_config_readonly__writing_to_readonly_fails
(
void
)
{
git_config_backend
*
backend
;
cl_git_pass
(
git_config_file__ondisk
(
&
backend
,
"global"
));
backend
->
readonly
=
1
;
cl_git_pass
(
git_config_add_backend
(
cfg
,
backend
,
GIT_CONFIG_LEVEL_GLOBAL
,
0
));
cl_git_fail_with
(
GIT_ENOTFOUND
,
git_config_set_string
(
cfg
,
"foo.bar"
,
"baz"
));
cl_assert
(
!
git_path_exists
(
"global"
));
}
void
test_config_readonly__writing_to_cfg_with_rw_precedence_succeeds
(
void
)
{
git_config_backend
*
backend
;
cl_git_pass
(
git_config_file__ondisk
(
&
backend
,
"global"
));
backend
->
readonly
=
1
;
cl_git_pass
(
git_config_add_backend
(
cfg
,
backend
,
GIT_CONFIG_LEVEL_GLOBAL
,
0
));
cl_git_pass
(
git_config_file__ondisk
(
&
backend
,
"local"
));
cl_git_pass
(
git_config_add_backend
(
cfg
,
backend
,
GIT_CONFIG_LEVEL_LOCAL
,
0
));
cl_git_pass
(
git_config_set_string
(
cfg
,
"foo.bar"
,
"baz"
));
cl_assert
(
git_path_exists
(
"local"
));
cl_assert
(
!
git_path_exists
(
"global"
));
cl_git_pass
(
p_unlink
(
"local"
));
}
void
test_config_readonly__writing_to_cfg_with_ro_precedence_succeeds
(
void
)
{
git_config_backend
*
backend
;
cl_git_pass
(
git_config_file__ondisk
(
&
backend
,
"local"
));
backend
->
readonly
=
1
;
cl_git_pass
(
git_config_add_backend
(
cfg
,
backend
,
GIT_CONFIG_LEVEL_LOCAL
,
0
));
cl_git_pass
(
git_config_file__ondisk
(
&
backend
,
"global"
));
cl_git_pass
(
git_config_add_backend
(
cfg
,
backend
,
GIT_CONFIG_LEVEL_GLOBAL
,
0
));
cl_git_pass
(
git_config_set_string
(
cfg
,
"foo.bar"
,
"baz"
));
cl_assert
(
!
git_path_exists
(
"local"
));
cl_assert
(
git_path_exists
(
"global"
));
cl_git_pass
(
p_unlink
(
"global"
));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment