diff options
| author | Vicent Martà <vicent@github.com> | 2012-02-15 11:38:40 -0800 |
|---|---|---|
| committer | Vicent Martà <vicent@github.com> | 2012-02-15 11:38:40 -0800 |
| commit | 6117895fef92ddd08c437ce5a7cdc4bf56754cc3 (patch) | |
| tree | a38b27a3bab5c44daaab2c6b07438dc3e5cf67d9 /tests-clar | |
| parent | 0c3bae6268c404fc3717cc90ba1bc5db91c8cbe6 (diff) | |
| parent | bf477ed4a86d4183f7e38e4667a1f623270bf5d2 (diff) | |
| download | libgit2-6117895fef92ddd08c437ce5a7cdc4bf56754cc3.tar.gz | |
Merge pull request #558 from schu/notes-api
Notes API
Diffstat (limited to 'tests-clar')
| -rw-r--r-- | tests-clar/commit/commit.c | 44 | ||||
| -rw-r--r-- | tests-clar/notes/notes.c | 49 |
2 files changed, 93 insertions, 0 deletions
diff --git a/tests-clar/commit/commit.c b/tests-clar/commit/commit.c new file mode 100644 index 000000000..1205e5285 --- /dev/null +++ b/tests-clar/commit/commit.c @@ -0,0 +1,44 @@ +#include "clar_libgit2.h" + +static git_repository *_repo; + +void test_commit_commit__initialize(void) +{ + cl_fixture_sandbox("testrepo.git"); + cl_git_pass(git_repository_open(&_repo, "testrepo.git")); +} + +void test_commit_commit__cleanup(void) +{ + git_repository_free(_repo); + cl_fixture_cleanup("testrepo.git"); +} + +void test_commit_commit__create_unexisting_update_ref(void) +{ + git_oid oid; + git_tree *tree; + git_commit *commit; + git_signature *s; + git_reference *ref; + + git_oid_fromstr(&oid, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); + cl_git_pass(git_commit_lookup(&commit, _repo, &oid)); + + git_oid_fromstr(&oid, "944c0f6e4dfa41595e6eb3ceecdb14f50fe18162"); + cl_git_pass(git_tree_lookup(&tree, _repo, &oid)); + + cl_git_pass(git_signature_now(&s, "alice", "alice@example.com")); + + cl_git_fail(git_reference_lookup(&ref, _repo, "refs/heads/foo/bar")); + cl_git_pass(git_commit_create(&oid, _repo, "refs/heads/foo/bar", s, s, + NULL, "some msg", tree, 1, (const git_commit **) &commit)); + + cl_git_pass(git_reference_lookup(&ref, _repo, "refs/heads/foo/bar")); + cl_assert(!git_oid_cmp(&oid, git_reference_oid(ref))); + + git_tree_free(tree); + git_commit_free(commit); + git_signature_free(s); + git_reference_free(ref); +} diff --git a/tests-clar/notes/notes.c b/tests-clar/notes/notes.c new file mode 100644 index 000000000..eeb25eca0 --- /dev/null +++ b/tests-clar/notes/notes.c @@ -0,0 +1,49 @@ +#include "clar_libgit2.h" + +static git_repository *_repo; +static git_note *_note; +static git_blob *_blob; +static git_signature *_sig; + +void test_notes_notes__initialize(void) +{ + cl_fixture_sandbox("testrepo.git"); + cl_git_pass(git_repository_open(&_repo, "testrepo.git")); +} + +void test_notes_notes__cleanup(void) +{ + git_note_free(_note); + git_blob_free(_blob); + git_signature_free(_sig); + + git_repository_free(_repo); + cl_fixture_cleanup("testrepo.git"); +} + +void test_notes_notes__1(void) +{ + git_oid oid, note_oid; + + cl_git_pass(git_signature_now(&_sig, "alice", "alice@example.com")); + + cl_git_pass(git_note_create(¬e_oid, _repo, _sig, _sig, "refs/notes/some/namespace", &oid, "hello world\n")); + cl_git_pass(git_note_create(¬e_oid, _repo, _sig, _sig, NULL, &oid, "hello world\n")); + + cl_git_pass(git_note_read(&_note, _repo, NULL, &oid)); + + cl_assert(!strcmp(git_note_message(_note), "hello world\n")); + cl_assert(!git_oid_cmp(git_note_oid(_note), ¬e_oid)); + + cl_git_pass(git_blob_lookup(&_blob, _repo, ¬e_oid)); + cl_assert(!strcmp(git_note_message(_note), git_blob_rawcontent(_blob))); + + cl_git_fail(git_note_create(¬e_oid, _repo, _sig, _sig, NULL, &oid, "hello world\n")); + cl_git_fail(git_note_create(¬e_oid, _repo, _sig, _sig, "refs/notes/some/namespace", &oid, "hello world\n")); + + cl_git_pass(git_note_remove(_repo, NULL, _sig, _sig, &oid)); + cl_git_pass(git_note_remove(_repo, "refs/notes/some/namespace", _sig, _sig, &oid)); + + cl_git_fail(git_note_remove(_repo, NULL, _sig, _sig, ¬e_oid)); + cl_git_fail(git_note_remove(_repo, "refs/notes/some/namespace", _sig, _sig, &oid)); +} |
