summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Lobanov <gaussblurinc@gmail.com>2021-06-03 11:14:58 +0300
committerDmitry Lobanov <gaussblurinc@gmail.com>2021-06-03 11:14:58 +0300
commit11452ca143ebe063419b4991f5ee8279d9fbecee (patch)
tree8f3e444c375ad35db4c1402de11ed05e8de40673
parentca2ff5abb8d321b185007be11ea1ad8959e9708d (diff)
downloadlibgit2-11452ca143ebe063419b4991f5ee8279d9fbecee.tar.gz
tests: submodule git lookup can be dupped test has been added.
-rw-r--r--tests/submodule/lookup.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/submodule/lookup.c b/tests/submodule/lookup.c
index 6f7506d2c..84ecd8539 100644
--- a/tests/submodule/lookup.c
+++ b/tests/submodule/lookup.c
@@ -42,6 +42,46 @@ void test_submodule_lookup__simple_lookup(void)
assert_submodule_exists(g_repo, "sm_added_and_uncommited/");
}
+void test_submodule_lookup__can_be_dupped(void)
+{
+ git_submodule *sm;
+ git_submodule *sm_duplicate;
+ const char *oid = "480095882d281ed676fe5b863569520e54a7d5c0";
+
+ // Check original
+ cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged"));
+ cl_assert(git_submodule_owner(sm) == g_repo);
+ cl_assert_equal_s("sm_unchanged", git_submodule_name(sm));
+ cl_assert(git__suffixcmp(git_submodule_path(sm), "sm_unchanged") == 0);
+ cl_assert(git__suffixcmp(git_submodule_url(sm), "/submod2_target") == 0);
+
+ cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_head_id(sm), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_wd_id(sm), oid) == 0);
+
+ cl_assert(git_submodule_ignore(sm) == GIT_SUBMODULE_IGNORE_NONE);
+ cl_assert(git_submodule_update_strategy(sm) == GIT_SUBMODULE_UPDATE_CHECKOUT);
+
+ // Duplicate and free original
+ cl_assert(git_submodule_dup(&sm_duplicate, sm) == 0);
+ git_submodule_free(sm);
+
+ // Check duplicate
+ cl_assert(git_submodule_owner(sm_duplicate) == g_repo);
+ cl_assert_equal_s("sm_unchanged", git_submodule_name(sm_duplicate));
+ cl_assert(git__suffixcmp(git_submodule_path(sm_duplicate), "sm_unchanged") == 0);
+ cl_assert(git__suffixcmp(git_submodule_url(sm_duplicate), "/submod2_target") == 0);
+
+ cl_assert(git_oid_streq(git_submodule_index_id(sm_duplicate), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_head_id(sm_duplicate), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_wd_id(sm_duplicate), oid) == 0);
+
+ cl_assert(git_submodule_ignore(sm_duplicate) == GIT_SUBMODULE_IGNORE_NONE);
+ cl_assert(git_submodule_update_strategy(sm_duplicate) == GIT_SUBMODULE_UPDATE_CHECKOUT);
+
+ git_submodule_free(sm_duplicate);
+}
+
void test_submodule_lookup__accessors(void)
{
git_submodule *sm;