diff options
author | Patrick Steinhardt <ps@pks.im> | 2019-10-17 13:43:26 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2019-10-17 13:43:26 +0200 |
commit | 73e9535d02aa0f438954ae929d8f6141f496a5a2 (patch) | |
tree | 6d0fd94e5c3005024ef3705ccb0b8e1c38798307 | |
parent | de412fc29918ed2cb11e2e9beeb15f7890668bdf (diff) | |
download | libgit2-73e9535d02aa0f438954ae929d8f6141f496a5a2.tar.gz |
tests: submodule: test cloning edge cases
Add two more tests that verify our behaviour in some edge cases, notably
when cloning into a non-empty directory and when cloning the same
submodule twice.
-rw-r--r-- | tests/submodule/add.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/submodule/add.c b/tests/submodule/add.c index 76c3fff34..f4d1e3b79 100644 --- a/tests/submodule/add.c +++ b/tests/submodule/add.c @@ -212,3 +212,40 @@ void test_submodule_add__submodule_clone(void) git_submodule_free(sm); git_index_free(index); } + +void test_submodule_add__submodule_clone_into_nonempty_dir_succeeds(void) +{ + git_submodule *sm; + + g_repo = cl_git_sandbox_init("empty_standard_repo"); + + cl_git_pass(p_mkdir("empty_standard_repo/sm", 0777)); + cl_git_mkfile("empty_standard_repo/sm/foobar", ""); + + /* Create the submodule structure, clone into it and finalize */ + cl_git_pass(git_submodule_add_setup(&sm, g_repo, cl_fixture("testrepo.git"), "sm", true)); + cl_git_pass(git_submodule_clone(NULL, sm, NULL)); + cl_git_pass(git_submodule_add_finalize(sm)); + + cl_assert(git_path_exists("empty_standard_repo/sm/foobar")); + + assert_submodule_exists(g_repo, "sm"); + + git_submodule_free(sm); +} + +void test_submodule_add__submodule_clone_twice_fails(void) +{ + git_submodule *sm; + + 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"), "sm", true)); + cl_git_pass(git_submodule_clone(NULL, sm, NULL)); + cl_git_pass(git_submodule_add_finalize(sm)); + + cl_git_fail(git_submodule_clone(NULL, sm, NULL)); + + git_submodule_free(sm); +} |