Improve test coverage of new path prettifying behavior
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
diff --git a/tests/t12-repo.c b/tests/t12-repo.c
index 2c7f131..9b8933f 100644
--- a/tests/t12-repo.c
+++ b/tests/t12-repo.c
@@ -158,7 +158,7 @@ BEGIN_TEST(init1, "initialize a bare repo")
must_pass(ensure_repository_init(TEMP_REPO_FOLDER_NS, BARE_REPOSITORY, NULL, path_repository, NULL));
END_TEST
-BEGIN_TEST(init2, "Initialize a bare repo with a relative path escaping out of the current working directory")
+BEGIN_TEST(init2, "Initialize and open a bare repo with a relative path escaping out of the current working directory")
char path_repository[GIT_PATH_MAX];
char current_workdir[GIT_PATH_MAX];
const int mode = 0755; /* or 0777 ? */
@@ -176,6 +176,38 @@ BEGIN_TEST(init2, "Initialize a bare repo with a relative path escaping out of t
git_repository_free(repo);
+ must_pass(git_repository_open(&repo, "../d/e.git"));
+
+ git_repository_free(repo);
+
+ must_pass(chdir(current_workdir));
+ rmdir_recurs(TEMP_REPO_FOLDER);
+END_TEST
+
+BEGIN_TEST(open2, "Open a bare repository with a relative path escaping out of the current working directory")
+ char new_current_workdir[GIT_PATH_MAX];
+ char current_workdir[GIT_PATH_MAX];
+ char path_repository[GIT_PATH_MAX];
+
+ const int mode = 0755; /* or 0777 ? */
+ git_repository* repo;
+
+ /* Setup the repository to open */
+ must_pass(gitfo_getcwd(current_workdir, sizeof(current_workdir)));
+ strcpy(path_repository, current_workdir);
+ git__joinpath_n(path_repository, 3, path_repository, TEMP_REPO_FOLDER, "a/d/e.git");
+ must_pass(gitfo_mkdir_recurs(path_repository, mode));
+ must_pass(copydir_recurs(REPOSITORY_FOLDER, path_repository));
+
+ /* Change the current working directory */
+ git__joinpath(new_current_workdir, TEMP_REPO_FOLDER, "a/b/c/");
+ must_pass(gitfo_mkdir_recurs(new_current_workdir, mode));
+ must_pass(chdir(new_current_workdir));
+
+ must_pass(git_repository_open(&repo, "../../d/e.git"));
+
+ git_repository_free(repo);
+
must_pass(chdir(current_workdir));
rmdir_recurs(TEMP_REPO_FOLDER);
END_TEST
@@ -186,5 +218,6 @@ BEGIN_SUITE(repository)
ADD_TEST(init0);
ADD_TEST(init1);
ADD_TEST(init2);
+ ADD_TEST(open2);
END_SUITE