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
0e5a27cd
Commit
0e5a27cd
authored
Jun 20, 2018
by
Etienne Samson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: count config section helper already exists
parent
f8fc987c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
29 deletions
+12
-29
tests/remote/create.c
+12
-29
No files found.
tests/remote/create.c
View file @
0e5a27cd
#include "clar_libgit2.h"
#include "config/config_helpers.h"
static
git_repository
*
_repo
;
static
git_config
*
_config
;
...
...
@@ -13,25 +14,6 @@ static git_config *_config;
cl_assert_equal_p(r, NULL); \
} while (0);
static
int
cl_git_config_section_count__foreach
(
const
git_config_entry
*
entry
,
void
*
payload
)
{
size_t
*
count
=
payload
;
GIT_UNUSED
(
entry
);
(
*
count
)
++
;
return
0
;
}
static
size_t
cl_git_config_sections_count
(
git_config
*
cfg
,
const
char
*
regex
)
{
size_t
count
=
0
;
cl_git_pass
(
git_config_foreach_match
(
cfg
,
regex
,
cl_git_config_section_count__foreach
,
&
count
));
return
count
;
}
void
test_remote_create__initialize
(
void
)
{
cl_fixture_sandbox
(
"testrepo.git"
);
...
...
@@ -70,7 +52,7 @@ void test_remote_create__named(void)
git_config
*
cfg
;
const
char
*
cfg_val
;
size_t
section_count
=
c
l_git_config_sections_count
(
_config
,
"remote
."
);
size_t
section_count
=
c
ount_config_entries_match
(
_repo
,
"remote
\\
."
);
cl_git_pass
(
git_remote_create
(
&
remote
,
_repo
,
"valid-name"
,
TEST_URL
));
...
...
@@ -86,7 +68,7 @@ void test_remote_create__named(void)
cl_git_pass
(
git_config_get_string
(
&
cfg_val
,
cfg
,
"remote.valid-name.url"
));
cl_assert_equal_s
(
cfg_val
,
TEST_URL
);
cl_assert_equal_i
(
section_count
+
2
,
c
l_git_config_sections_count
(
_config
,
"remote
."
));
cl_assert_equal_i
(
section_count
+
2
,
c
ount_config_entries_match
(
_repo
,
"remote
\\
."
));
git_config_free
(
cfg
);
git_remote_free
(
remote
);
...
...
@@ -117,7 +99,7 @@ void test_remote_create__with_fetchspec(void)
{
git_remote
*
remote
;
git_strarray
array
;
size_t
section_count
=
c
l_git_config_sections_count
(
_config
,
"remote
."
);
size_t
section_count
=
c
ount_config_entries_match
(
_repo
,
"remote
\\
."
);
cl_git_pass
(
git_remote_create_with_fetchspec
(
&
remote
,
_repo
,
"test-new"
,
"git://github.com/libgit2/libgit2"
,
"+refs/*:refs/*"
));
cl_assert_equal_s
(
git_remote_name
(
remote
),
"test-new"
);
...
...
@@ -127,7 +109,7 @@ void test_remote_create__with_fetchspec(void)
cl_git_pass
(
git_remote_get_fetch_refspecs
(
&
array
,
remote
));
cl_assert_equal_s
(
"+refs/*:refs/*"
,
array
.
strings
[
0
]);
cl_assert_equal_i
(
1
,
array
.
count
);
cl_assert_equal_i
(
section_count
+
2
,
c
l_git_config_sections_count
(
_config
,
"remote
."
));
cl_assert_equal_i
(
section_count
+
2
,
c
ount_config_entries_match
(
_repo
,
"remote
\\
."
));
git_strarray_free
(
&
array
);
git_remote_free
(
remote
);
...
...
@@ -137,12 +119,12 @@ void test_remote_create__with_empty_fetchspec(void)
{
git_remote
*
remote
;
git_strarray
array
;
size_t
section_count
=
c
l_git_config_sections_count
(
_config
,
"remote
."
);
size_t
section_count
=
c
ount_config_entries_match
(
_repo
,
"remote
\\
."
);
cl_git_pass
(
git_remote_create_with_fetchspec
(
&
remote
,
_repo
,
"test-new"
,
"git://github.com/libgit2/libgit2"
,
NULL
));
cl_git_pass
(
git_remote_get_fetch_refspecs
(
&
array
,
remote
));
cl_assert_equal_i
(
0
,
array
.
count
);
cl_assert_equal_i
(
section_count
+
1
,
c
l_git_config_sections_count
(
_config
,
"remote
."
));
cl_assert_equal_i
(
section_count
+
1
,
c
ount_config_entries_match
(
_repo
,
"remote
\\
."
));
git_strarray_free
(
&
array
);
git_remote_free
(
remote
);
...
...
@@ -162,7 +144,7 @@ void test_remote_create__anonymous(void)
{
git_remote
*
remote
;
git_strarray
array
;
size_t
section_count
=
c
l_git_config_sections_count
(
_config
,
"remote
."
);
size_t
section_count
=
c
ount_config_entries_match
(
_repo
,
"remote
\\
."
);
cl_git_pass
(
git_remote_create_anonymous
(
&
remote
,
_repo
,
TEST_URL
));
cl_assert_equal_s
(
git_remote_name
(
remote
),
NULL
);
...
...
@@ -171,7 +153,7 @@ void test_remote_create__anonymous(void)
cl_git_pass
(
git_remote_get_fetch_refspecs
(
&
array
,
remote
));
cl_assert_equal_i
(
0
,
array
.
count
);
cl_assert_equal_i
(
section_count
,
c
l_git_config_sections_count
(
_config
,
"remote
."
));
cl_assert_equal_i
(
section_count
,
c
ount_config_entries_match
(
_repo
,
"remote
\\
."
));
git_strarray_free
(
&
array
);
git_remote_free
(
remote
);
...
...
@@ -186,7 +168,8 @@ void test_remote_create__detached(void)
{
git_remote
*
remote
;
git_strarray
array
;
size_t
section_count
=
cl_git_config_sections_count
(
_config
,
"remote."
);
size_t
section_count
=
count_config_entries_match
(
_repo
,
"remote
\\
."
);
cl_git_pass
(
git_remote_create_detached
(
&
remote
,
TEST_URL
));
cl_assert_equal_s
(
git_remote_name
(
remote
),
NULL
);
...
...
@@ -195,7 +178,7 @@ void test_remote_create__detached(void)
cl_git_pass
(
git_remote_get_fetch_refspecs
(
&
array
,
remote
));
cl_assert_equal_i
(
0
,
array
.
count
);
cl_assert_equal_i
(
section_count
,
c
l_git_config_sections_count
(
_config
,
"remote
."
));
cl_assert_equal_i
(
section_count
,
c
ount_config_entries_match
(
_repo
,
"remote
\\
."
));
git_strarray_free
(
&
array
);
git_remote_free
(
remote
);
...
...
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