Add passing reflog tests
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/tests/refs/branches/create.c b/tests/refs/branches/create.c
index e4ad668..43614bd 100644
--- a/tests/refs/branches/create.c
+++ b/tests/refs/branches/create.c
@@ -66,7 +66,6 @@ void test_refs_branches_create__can_force_create_over_an_existing_branch(void)
cl_assert_equal_s("refs/heads/br2", git_reference_name(branch));
}
-
void test_refs_branches_create__creating_a_branch_with_an_invalid_name_returns_EINVALIDSPEC(void)
{
retrieve_known_commit(&target, repo);
@@ -75,3 +74,32 @@ void test_refs_branches_create__creating_a_branch_with_an_invalid_name_returns_E
git_branch_create(&branch, repo, "inv@{id", target, 0));
}
+void test_refs_branches_create__creation_creates_new_reflog(void)
+{
+ git_reflog *log;
+ const git_reflog_entry *entry;
+
+ retrieve_known_commit(&target, repo);
+ cl_git_pass(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, false));
+ cl_git_pass(git_reflog_read(&log, repo, "refs/heads/" NEW_BRANCH_NAME));
+
+ cl_assert_equal_i(1, git_reflog_entrycount(log));
+ entry = git_reflog_entry_byindex(log, 0);
+}
+
+void test_refs_branches_create__recreation_updates_existing_reflog(void)
+{
+ git_reflog *log;
+ const git_reflog_entry *entry;
+
+ retrieve_known_commit(&target, repo);
+
+ cl_git_pass(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, false));
+ cl_git_pass(git_branch_delete(branch));
+ cl_git_pass(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, false));
+ cl_git_pass(git_reflog_read(&log, repo, "refs/heads/" NEW_BRANCH_NAME));
+
+ cl_assert_equal_i(2, git_reflog_entrycount(log));
+ entry = git_reflog_entry_byindex(log, 0);
+}
+