summaryrefslogtreecommitdiff
path: root/tests/submodule
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-10-17 13:36:22 +0200
committerPatrick Steinhardt <ps@pks.im>2019-10-17 13:37:25 +0200
commitde412fc29918ed2cb11e2e9beeb15f7890668bdf (patch)
tree2a60cde2e68d2f82b99542b64e0f688a4d900c3f /tests/submodule
parent09b1ac11b4ad53a9a0e7e3a2dc2cdfe4614186ea (diff)
downloadlibgit2-de412fc29918ed2cb11e2e9beeb15f7890668bdf.tar.gz
tests: submodule: make use of sandboxes to clean repos
The test submodule::add::submodule_clone doesn't use a sandbox, and thus the created repo will not get deleted after the test has finished. Convert the test to use the empty standard repo sandbox instead to fix this.
Diffstat (limited to 'tests/submodule')
-rw-r--r--tests/submodule/add.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/submodule/add.c b/tests/submodule/add.c
index e79d07961..76c3fff34 100644
--- a/tests/submodule/add.c
+++ b/tests/submodule/add.c
@@ -187,28 +187,28 @@ void test_submodule_add__file_exists_in_index(void)
void test_submodule_add__submodule_clone(void)
{
- git_index *index;
git_oid tree_id, commit_id;
- git_submodule *sm;
git_signature *sig;
+ git_submodule *sm;
+ git_index *index;
- cl_git_pass(git_repository_init(&g_repo, "willaddsubmodule-add", false));
+ g_repo = cl_git_sandbox_init("empty_standard_repo");
/* Create the submodule structure, clone into it and finalize */
cl_git_pass(git_submodule_add_setup(&sm, g_repo, cl_fixture("testrepo.git"), "testrepo-add", true));
cl_git_pass(git_submodule_clone(NULL, sm, NULL));
cl_git_pass(git_submodule_add_finalize(sm));
- git_submodule_free(sm);
+ /* Create the submodule commit */
cl_git_pass(git_repository_index(&index, g_repo));
cl_git_pass(git_index_write_tree(&tree_id, index));
- git_index_free(index);
-
cl_git_pass(git_signature_now(&sig, "Submoduler", "submoduler@local"));
cl_git_pass(git_commit_create_from_ids(&commit_id, g_repo, "HEAD", sig, sig, NULL, "A submodule\n",
- &tree_id, 0, NULL));
-
- git_signature_free(sig);
+ &tree_id, 0, NULL));
assert_submodule_exists(g_repo, "testrepo-add");
+
+ git_signature_free(sig);
+ git_submodule_free(sm);
+ git_index_free(index);
}