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
705a90ec
Commit
705a90ec
authored
Feb 26, 2011
by
nulltoken
Committed by
Vicent Marti
Mar 03, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests to exercise the initialization and the opening of a repository.
parent
c38f9013
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
tests/t12-repo.c
+47
-0
No files found.
tests/t12-repo.c
View file @
705a90ec
...
...
@@ -27,6 +27,7 @@
#include "odb.h"
#include "git2/odb_backend.h"
#include "repository.h"
typedef
struct
{
git_odb_backend
base
;
...
...
@@ -89,12 +90,58 @@ BEGIN_TEST("odb", backend_alternates_sorting)
git_odb_close
(
odb
);
END_TEST
#define WORK_TREE_WITHOUT_TRAILING_SLASH TEST_RESOURCES "/temp_working"
#define WORK_TREE_WITH_TRAILING_SLASH WORK_TREE_WITHOUT_TRAILING_SLASH "/"
#define STANDARD_REPOSITORY 0
#define BARE_REPOSITORY 1
static
void
ensure_repository_init
(
git_test
*
_gittest
,
char
*
working_directory
,
int
repository_kind
,
char
*
expected_path_index
,
char
*
expected_path_repository
,
char
*
expected_working_directory
)
{
char
path_odb
[
GIT_PATH_MAX
];
git_repository
*
repo
;
must_be_true
(
gitfo_isdir
(
working_directory
));
git__joinpath
(
path_odb
,
expected_path_repository
,
GIT_OBJECTS_DIR
);
must_pass
(
git_repository_init
(
&
repo
,
working_directory
,
repository_kind
));
must_be_true
((
repo
->
path_workdir
==
NULL
&&
expected_working_directory
==
NULL
)
||
!
strcmp
(
repo
->
path_workdir
,
expected_working_directory
));
must_be_true
(
!
strcmp
(
repo
->
path_odb
,
path_odb
));
must_be_true
(
!
strcmp
(
repo
->
path_repository
,
expected_path_repository
));
must_be_true
((
repo
->
path_index
==
NULL
&&
expected_path_index
==
NULL
)
||
!
strcmp
(
repo
->
path_index
,
expected_path_index
));
git_repository_free
(
repo
);
must_pass
(
rmdir_recurs
(
working_directory
));
}
BEGIN_TEST
(
"repo_initialization"
,
init_standard_repo
)
char
path_index
[
GIT_PATH_MAX
],
path_repository
[
GIT_PATH_MAX
];
git__joinpath
(
path_repository
,
WORK_TREE_WITH_TRAILING_SLASH
,
GIT_DIR
);
git__joinpath
(
path_index
,
path_repository
,
GIT_INDEX_FILE
);
ensure_repository_init
(
_gittest
,
WORK_TREE_WITH_TRAILING_SLASH
,
STANDARD_REPOSITORY
,
path_index
,
path_repository
,
WORK_TREE_WITH_TRAILING_SLASH
);
ensure_repository_init
(
_gittest
,
WORK_TREE_WITHOUT_TRAILING_SLASH
,
STANDARD_REPOSITORY
,
path_index
,
path_repository
,
WORK_TREE_WITH_TRAILING_SLASH
);
END_TEST
BEGIN_TEST
(
"repo_initialization"
,
init_bare_repo
)
char
path_repository
[
GIT_PATH_MAX
];
git__joinpath
(
path_repository
,
WORK_TREE_WITH_TRAILING_SLASH
,
""
);
ensure_repository_init
(
_gittest
,
WORK_TREE_WITH_TRAILING_SLASH
,
BARE_REPOSITORY
,
NULL
,
path_repository
,
NULL
);
ensure_repository_init
(
_gittest
,
WORK_TREE_WITHOUT_TRAILING_SLASH
,
BARE_REPOSITORY
,
NULL
,
path_repository
,
NULL
);
END_TEST
git_testsuite
*
libgit2_suite_repository
(
void
)
{
git_testsuite
*
suite
=
git_testsuite_new
(
"Repository"
);
ADD_TEST
(
suite
,
"odb"
,
backend_sorting
);
ADD_TEST
(
suite
,
"odb"
,
backend_alternates_sorting
);
ADD_TEST
(
suite
,
"repo_initialization"
,
init_standard_repo
);
ADD_TEST
(
suite
,
"repo_initialization"
,
init_bare_repo
);
return
suite
;
}
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