diff options
author | Richard Ipsum <richardipsum@fastmail.co.uk> | 2017-03-19 18:34:07 +0000 |
---|---|---|
committer | Richard Ipsum <richardipsum@fastmail.co.uk> | 2017-10-07 00:43:40 +0100 |
commit | 60bee89d4697832f88c484f0c236e7f25c3d62fe (patch) | |
tree | 9670114f2cd4510c1c195c2281a04c4d1aaeee95 /tests/notes/notes.c | |
parent | 9a02725d11acb302b0d9ef7013ae81ffd59525c7 (diff) | |
download | libgit2-60bee89d4697832f88c484f0c236e7f25c3d62fe.tar.gz |
notes: Add git_note_commit_iterator_new
This also adds tests for this function.
Diffstat (limited to 'tests/notes/notes.c')
-rw-r--r-- | tests/notes/notes.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/notes/notes.c b/tests/notes/notes.c index dcf607d00..dc7fdea98 100644 --- a/tests/notes/notes.c +++ b/tests/notes/notes.c @@ -594,3 +594,46 @@ void test_notes_notes__empty_iterate(void) cl_git_fail(git_note_iterator_new(&iter, _repo, "refs/notes/commits")); } + +void test_notes_notes__iterate_from_commit(void) +{ + git_note_iterator *iter; + git_note *note; + git_oid note_id, annotated_id; + git_oid oids[2]; + git_oid notes_commit_oids[2]; + git_commit *notes_commits[2]; + const char* note_message[] = { + "I decorate a65f\n", + "I decorate c478\n" + }; + int i, err; + + cl_git_pass(git_oid_fromstr(&(oids[0]), "a65fedf39aefe402d3bb6e24df4d4f5fe4547750")); + cl_git_pass(git_oid_fromstr(&(oids[1]), "c47800c7266a2be04c571c04d5a6614691ea99bd")); + + cl_git_pass(git_note_commit_create(¬es_commit_oids[0], NULL, _repo, NULL, _sig, _sig, &(oids[0]), note_message[0], 0)); + + git_commit_lookup(¬es_commits[0], _repo, ¬es_commit_oids[0]); + cl_assert(notes_commits[0]); + + cl_git_pass(git_note_commit_create(¬es_commit_oids[1], NULL, _repo, notes_commits[0], _sig, _sig, &(oids[1]), note_message[1], 0)); + + git_commit_lookup(¬es_commits[1], _repo, ¬es_commit_oids[1]); + cl_assert(notes_commits[1]); + + cl_git_pass(git_note_commit_iterator_new(&iter, notes_commits[1])); + + for (i = 0; (err = git_note_next(¬e_id, &annotated_id, iter)) >= 0; ++i) { + cl_git_pass(git_note_commit_read(¬e, _repo, notes_commits[1], &annotated_id)); + cl_assert_equal_s(git_note_message(note), note_message[i]); + git_note_free(note); + } + + cl_assert_equal_i(GIT_ITEROVER, err); + cl_assert_equal_i(2, i); + + git_note_iterator_free(iter); + git_commit_free(notes_commits[0]); + git_commit_free(notes_commits[1]); +} |