diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/commit/write.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/commit/write.c b/tests/commit/write.c index 96b7cc321..9d1ae78fb 100644 --- a/tests/commit/write.c +++ b/tests/commit/write.c @@ -98,6 +98,45 @@ void test_commit_write__from_memory(void) cl_assert_equal_s(commit_message, git_commit_message(commit)); } +void test_commit_write__into_buf(void) +{ + git_oid tree_id; + git_signature *author, *committer; + git_tree *tree; + git_commit *parent; + git_oid parent_id; + git_buf commit = GIT_BUF_INIT; + + git_oid_fromstr(&tree_id, tree_id_str); + cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id)); + + /* create signatures */ + cl_git_pass(git_signature_new(&committer, committer_name, committer_email, 123456789, 60)); + cl_git_pass(git_signature_new(&author, committer_name, committer_email, 987654321, 90)); + + git_oid_fromstr(&parent_id, parent_id_str); + cl_git_pass(git_commit_lookup(&parent, g_repo, &parent_id)); + + cl_git_pass(git_commit_create_buffer(&commit, g_repo, author, committer, + NULL, root_commit_message, tree, 1, (const git_commit **) &parent)); + + cl_assert_equal_s(commit.ptr, + "tree 1810dff58d8a660512d4832e740f692884338ccd\n\ +parent 8496071c1b46c854b31185ea97743be6a8774479\n\ +author Vicent Marti <vicent@github.com> 987654321 +0130\n\ +committer Vicent Marti <vicent@github.com> 123456789 +0100\n\ +\n\ +This is a root commit\n\ + This is a root commit and should be the only one in this branch\n\ +"); + + git_buf_free(&commit); + git_tree_free(tree); + git_commit_free(parent); + git_signature_free(author); + git_signature_free(committer); +} + // create a root commit void test_commit_write__root(void) { |