diff options
author | Nikolai Vladimirov <nikolay@vladimiroff.com> | 2013-01-03 16:31:36 +0200 |
---|---|---|
committer | Nikolai Vladimirov <nikolay@vladimiroff.com> | 2013-01-03 16:31:36 +0200 |
commit | 8716b499e246496171aa8e9b84563b9486d66033 (patch) | |
tree | ab70ff46732e081e74b3eb16f65295c92f31c68f /tests-clar/notes/notes.c | |
parent | 4a44087ae75a63ab0c10be215722a8a24f1187e7 (diff) | |
download | libgit2-8716b499e246496171aa8e9b84563b9486d66033.tar.gz |
add option to allow git note overwrite
Diffstat (limited to 'tests-clar/notes/notes.c')
-rw-r--r-- | tests-clar/notes/notes.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/tests-clar/notes/notes.c b/tests-clar/notes/notes.c index 3f5194c51..ee0b6c2f8 100644 --- a/tests-clar/notes/notes.c +++ b/tests-clar/notes/notes.c @@ -34,7 +34,7 @@ static void create_note(git_oid *note_oid, const char *canonical_namespace, cons git_oid oid; cl_git_pass(git_oid_fromstr(&oid, target_sha)); - cl_git_pass(git_note_create(note_oid, _repo, _sig, _sig, canonical_namespace, &oid, message)); + cl_git_pass(git_note_create(note_oid, _repo, _sig, _sig, canonical_namespace, &oid, message, 0)); } static struct { @@ -194,16 +194,40 @@ void test_notes_notes__creating_a_note_on_a_target_which_already_has_one_returns cl_git_pass(git_oid_fromstr(&target_oid, "08b041783f40edfe12bb406c9c9a8a040177c125")); create_note(¬e_oid, NULL, "08b041783f40edfe12bb406c9c9a8a040177c125", "hello world\n"); - error = git_note_create(¬e_oid, _repo, _sig, _sig, NULL, &target_oid, "hello world\n"); + error = git_note_create(¬e_oid, _repo, _sig, _sig, NULL, &target_oid, "hello world\n", 0); cl_git_fail(error); cl_assert_equal_i(GIT_EEXISTS, error); create_note(¬e_oid, "refs/notes/some/namespace", "08b041783f40edfe12bb406c9c9a8a040177c125", "hello world\n"); - error = git_note_create(¬e_oid, _repo, _sig, _sig, "refs/notes/some/namespace", &target_oid, "hello world\n"); + error = git_note_create(¬e_oid, _repo, _sig, _sig, "refs/notes/some/namespace", &target_oid, "hello world\n", 0); cl_git_fail(error); cl_assert_equal_i(GIT_EEXISTS, error); } + +void test_notes_notes__creating_a_note_on_a_target_can_overwrite_existing_note(void) +{ + git_oid note_oid, target_oid; + git_note *note, *namespace_note; + + cl_git_pass(git_oid_fromstr(&target_oid, "08b041783f40edfe12bb406c9c9a8a040177c125")); + + create_note(¬e_oid, NULL, "08b041783f40edfe12bb406c9c9a8a040177c125", "hello old world\n"); + cl_git_pass(git_note_create(¬e_oid, _repo, _sig, _sig, NULL, &target_oid, "hello new world\n", 1)); + + cl_git_pass(git_note_read(¬e, _repo, NULL, &target_oid)); + assert_note_equal(note, "hello new world\n", ¬e_oid); + + create_note(¬e_oid, "refs/notes/some/namespace", "08b041783f40edfe12bb406c9c9a8a040177c125", "hello old world\n"); + cl_git_pass(git_note_create(¬e_oid, _repo, _sig, _sig, "refs/notes/some/namespace", &target_oid, "hello new ref world\n", 1)); + + cl_git_pass(git_note_read(&namespace_note, _repo, "refs/notes/some/namespace", &target_oid)); + assert_note_equal(namespace_note, "hello new ref world\n", ¬e_oid); + + git_note_free(note); + git_note_free(namespace_note); +} + static char *messages[] = { "08c041783f40edfe12bb406c9c9a8a040177c125", "96c45fbe09ab7445fc7c60fd8d17f32494399343", @@ -244,7 +268,7 @@ void test_notes_notes__can_insert_a_note_in_an_existing_fanout(void) cl_git_pass(git_oid_fromstr(&target_oid, "08b041783f40edfe12bb406c9c9a8a040177c125")); for (i = 0; i < MESSAGES_COUNT; i++) { - cl_git_pass(git_note_create(¬e_oid, _repo, _sig, _sig, "refs/notes/fanout", &target_oid, messages[i])); + cl_git_pass(git_note_create(¬e_oid, _repo, _sig, _sig, "refs/notes/fanout", &target_oid, messages[i], 0)); cl_git_pass(git_note_read(&_note, _repo, "refs/notes/fanout", &target_oid)); git_note_free(_note); |