Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-05-05 10:22:35 +0300
committerCarlos Martín Nieto <cmn@dwim.me>2015-06-22 18:02:55 +0300
commitd6073b30f38f95aa25b1545cccac38261b359de1 (patch)
tree7a5a84001d63bf1574913757a01c50b14ac85aab /tests/submodule
parent486ba4cdd3d30c202d0c7ed202d6122a7e2b5164 (diff)
submodule: make `_set_url()` affect the configuration
With this one, we can get rid of the edit_and_save test.
Diffstat (limited to 'tests/submodule')
-rw-r--r--tests/submodule/init.c6
-rw-r--r--tests/submodule/modify.c45
2 files changed, 9 insertions, 42 deletions
diff --git a/tests/submodule/init.c b/tests/submodule/init.c
index dbde0f284..9e0cf5753 100644
--- a/tests/submodule/init.c
+++ b/tests/submodule/init.c
@@ -23,10 +23,10 @@ void test_submodule_init__absolute_url(void)
cl_assert(git_path_dirname_r(&absolute_url, git_repository_workdir(g_repo)) > 0);
cl_git_pass(git_buf_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git"));
- cl_git_pass(git_submodule_lookup(&sm, g_repo, "testrepo"));
-
/* write the absolute url to the .gitmodules file*/
- cl_git_pass(git_submodule_set_url(sm, absolute_url.ptr));
+ cl_git_pass(git_submodule_set_url(g_repo, "testrepo", absolute_url.ptr));
+
+ cl_git_pass(git_submodule_lookup(&sm, g_repo, "testrepo"));
/* verify that the .gitmodules is set with an absolute path*/
cl_assert_equal_s(absolute_url.ptr, git_submodule_url(sm));
diff --git a/tests/submodule/modify.c b/tests/submodule/modify.c
index d0902b3e1..9c387a3b5 100644
--- a/tests/submodule/modify.c
+++ b/tests/submodule/modify.c
@@ -185,47 +185,14 @@ void test_submodule_modify__set_branch(void)
git_submodule_free(sm);
}
-void test_submodule_modify__edit_and_save(void)
+void test_submodule_modify__set_url(void)
{
- git_submodule *sm1, *sm2;
- char *old_url;
- git_repository *r2;
-
- cl_git_pass(git_submodule_lookup(&sm1, g_repo, "sm_changed_head"));
-
- old_url = git__strdup(git_submodule_url(sm1));
-
- /* modify properties of submodule */
- cl_git_pass(git_submodule_set_url(sm1, SM_LIBGIT2_URL));
- cl_assert_equal_s(SM_LIBGIT2_URL, git_submodule_url(sm1));
-
- /* revert without saving (and confirm setters return old value) */
- cl_git_pass(git_submodule_set_url(sm1, old_url));
-
- /* check that revert was successful */
- cl_assert_equal_s(old_url, git_submodule_url(sm1));
-
- /* modify properties of submodule (again) */
- cl_git_pass(git_submodule_set_url(sm1, SM_LIBGIT2_URL));
-
- /* call save */
- cl_git_pass(git_submodule_save(sm1));
-
- /* call reload and check that the new values are loaded */
- cl_git_pass(git_submodule_reload(sm1, 0));
-
- cl_assert_equal_s(SM_LIBGIT2_URL, git_submodule_url(sm1));
-
- /* open a second copy of the repo and compare submodule */
- cl_git_pass(git_repository_open(&r2, "submod2"));
- cl_git_pass(git_submodule_lookup(&sm2, r2, "sm_changed_head"));
-
- cl_assert_equal_s(SM_LIBGIT2_URL, git_submodule_url(sm2));
+ git_submodule *sm;
- git_submodule_free(sm1);
- git_submodule_free(sm2);
- git_repository_free(r2);
- git__free(old_url);
+ cl_git_pass(git_submodule_set_url(g_repo, "sm_changed_head", SM_LIBGIT2_URL));
+ cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head"));
+ cl_assert_equal_s(SM_LIBGIT2_URL, git_submodule_url(sm));
+ git_submodule_free(sm);
}
void test_submodule_modify__save_last(void)