diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-10-09 09:06:24 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-10-09 09:13:51 +0200 |
commit | 880dfc507ea4d19ff4d30a04b2d94617a91d34d6 (patch) | |
tree | d5c2664a6cfeb456d4ef3df2b742f258940ec39f | |
parent | 38e769cb22bd1dda0ae96c14e375f524d4fc47c3 (diff) | |
download | libgit2-880dfc507ea4d19ff4d30a04b2d94617a91d34d6.tar.gz |
tests: checkout::tree: extract check for status entrycount
There are multiple locations where we have the same code to check
whether the count of status list entries of a repository matches an
expected number. Extract that into a common function.
-rw-r--r-- | tests/checkout/tree.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/tests/checkout/tree.c b/tests/checkout/tree.c index c3475f411..d7e756914 100644 --- a/tests/checkout/tree.c +++ b/tests/checkout/tree.c @@ -10,6 +10,16 @@ static git_repository *g_repo; static git_checkout_options g_opts; static git_object *g_object; +static void assert_status_entrycount(git_repository *repo, size_t count) +{ + git_status_list *status; + + cl_git_pass(git_status_list_new(&status, repo, NULL)); + cl_assert_equal_i(count, git_status_list_entrycount(status)); + + git_status_list_free(status); +} + void test_checkout_tree__initialize(void) { g_repo = cl_git_sandbox_init("testrepo"); @@ -1480,7 +1490,6 @@ void test_checkout_tree__baseline_is_empty_when_no_index(void) git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; git_reference *head; git_object *obj; - git_status_list *status; size_t conflicts = 0; assert_on_branch(g_repo, "master"); @@ -1506,9 +1515,7 @@ void test_checkout_tree__baseline_is_empty_when_no_index(void) opts.checkout_strategy |= GIT_CHECKOUT_FORCE; cl_git_pass(git_checkout_tree(g_repo, obj, &opts)); - cl_git_pass(git_status_list_new(&status, g_repo, NULL)); - cl_assert_equal_i(0, git_status_list_entrycount(status)); - git_status_list_free(status); + assert_status_entrycount(g_repo, 0); git_object_free(obj); git_reference_free(head); @@ -1519,7 +1526,6 @@ void test_checkout_tree__mode_change_is_force_updated(void) git_index *index; git_reference *head; git_object *obj; - git_status_list *status; if (!cl_is_chmod_supported()) clar__skip(); @@ -1530,29 +1536,20 @@ void test_checkout_tree__mode_change_is_force_updated(void) cl_git_pass(git_reference_peel(&obj, head, GIT_OBJ_COMMIT)); cl_git_pass(git_reset(g_repo, obj, GIT_RESET_HARD, NULL)); - - cl_git_pass(git_status_list_new(&status, g_repo, NULL)); - cl_assert_equal_i(0, git_status_list_entrycount(status)); - git_status_list_free(status); + assert_status_entrycount(g_repo, 0); /* update the mode on-disk */ cl_must_pass(p_chmod("testrepo/README", 0755)); cl_git_pass(git_checkout_tree(g_repo, obj, &g_opts)); - - cl_git_pass(git_status_list_new(&status, g_repo, NULL)); - cl_assert_equal_i(0, git_status_list_entrycount(status)); - git_status_list_free(status); + assert_status_entrycount(g_repo, 0); /* update the mode on-disk and in the index */ cl_must_pass(p_chmod("testrepo/README", 0755)); cl_must_pass(git_index_add_bypath(index, "README")); cl_git_pass(git_checkout_tree(g_repo, obj, &g_opts)); - - cl_git_pass(git_status_list_new(&status, g_repo, NULL)); - cl_assert_equal_i(0, git_status_list_entrycount(status)); - git_status_list_free(status); + assert_status_entrycount(g_repo, 0); git_object_free(obj); git_reference_free(head); |