]> git.proxmox.com Git - libgit2.git/blob - tests/repo/message.c
Merge pull request #2144 from linquize/branch-f-current
[libgit2.git] / tests / repo / message.c
1 #include "clar_libgit2.h"
2 #include "buffer.h"
3 #include "refs.h"
4 #include "posix.h"
5
6 static git_repository *_repo;
7
8 void test_repo_message__initialize(void)
9 {
10 _repo = cl_git_sandbox_init("testrepo.git");
11 }
12
13 void test_repo_message__cleanup(void)
14 {
15 cl_git_sandbox_cleanup();
16 }
17
18 void test_repo_message__none(void)
19 {
20 git_buf actual = GIT_BUF_INIT;
21 cl_assert_equal_i(GIT_ENOTFOUND, git_repository_message(&actual, _repo));
22 }
23
24 void test_repo_message__message(void)
25 {
26 git_buf path = GIT_BUF_INIT, actual = GIT_BUF_INIT;
27 const char expected[] = "Test\n\nThis is a test of the emergency broadcast system\n";
28
29 cl_git_pass(git_buf_joinpath(&path, git_repository_path(_repo), "MERGE_MSG"));
30 cl_git_mkfile(git_buf_cstr(&path), expected);
31
32 cl_git_pass(git_repository_message(&actual, _repo));
33 cl_assert_equal_s(expected, git_buf_cstr(&actual));
34 git_buf_free(&actual);
35
36 cl_git_pass(p_unlink(git_buf_cstr(&path)));
37 cl_assert_equal_i(GIT_ENOTFOUND, git_repository_message(&actual, _repo));
38 git_buf_free(&path);
39 }