diff options
author | Richard Ipsum <richardipsum@fastmail.co.uk> | 2017-09-23 17:19:58 +0100 |
---|---|---|
committer | Richard Ipsum <richardipsum@fastmail.co.uk> | 2017-12-02 18:19:29 +0000 |
commit | 4623c25f700be43efc5138e39d52ecff4c240b02 (patch) | |
tree | fc94baf4c425440bcf3010afa3496cf7b4a04590 | |
parent | d788f42a9c5f7840ff6ff86e0b9b06a785f42bd2 (diff) | |
download | libgit2-4623c25f700be43efc5138e39d52ecff4c240b02.tar.gz |
notes: Add test that read of noteless commit fails
-rw-r--r-- | tests/notes/notes.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/notes/notes.c b/tests/notes/notes.c index dc7fdea98..9626f53b3 100644 --- a/tests/notes/notes.c +++ b/tests/notes/notes.c @@ -415,6 +415,31 @@ void test_notes_notes__can_read_a_note_from_a_commit(void) git_note_free(note); } +/* Test that we can read a commit with no note fails */ +void test_notes_notes__attempt_to_read_a_note_from_a_commit_with_no_note_fails(void) +{ + git_oid oid, notes_commit_oid; + git_commit *notes_commit; + git_note *note; + + cl_git_pass(git_oid_fromstr(&oid, "4a202b346bb0fb0db7eff3cffeb3c70babbd2045")); + + cl_git_pass(git_note_commit_create(¬es_commit_oid, NULL, _repo, NULL, _sig, _sig, &oid, "I decorate 4a20\n", 1)); + + git_commit_lookup(¬es_commit, _repo, ¬es_commit_oid); + + cl_git_pass(git_note_commit_remove(¬es_commit_oid, _repo, notes_commit, _sig, _sig, &oid)); + git_commit_free(notes_commit); + + git_commit_lookup(¬es_commit, _repo, ¬es_commit_oid); + + cl_assert(notes_commit); + + cl_git_fail_with(GIT_ENOTFOUND, git_note_commit_read(¬e, _repo, notes_commit, &oid)); + + git_commit_free(notes_commit); +} + /* * $ git ls-tree refs/notes/fanout * 040000 tree 4b22b35d44b5a4f589edf3dc89196399771796ea 84 |