]> git.proxmox.com Git - libgit2.git/blob - tests/repo/message.c
Merge pull request #2077 from libgit2/cmn/buf-out
[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 static git_buf _path;
8 static git_buf _actual;
9
10 void test_repo_message__initialize(void)
11 {
12 _repo = cl_git_sandbox_init("testrepo.git");
13 git_buf_init(&_actual, 0);
14 }
15
16 void test_repo_message__cleanup(void)
17 {
18 cl_git_sandbox_cleanup();
19 git_buf_free(&_path);
20 git_buf_free(&_actual);
21 }
22
23 void test_repo_message__none(void)
24 {
25 cl_assert_equal_i(GIT_ENOTFOUND, git_repository_message(&_actual, _repo));
26 }
27
28 void test_repo_message__message(void)
29 {
30 const char expected[] = "Test\n\nThis is a test of the emergency broadcast system\n";
31
32 cl_git_pass(git_buf_joinpath(&_path, git_repository_path(_repo), "MERGE_MSG"));
33 cl_git_mkfile(git_buf_cstr(&_path), expected);
34
35 cl_git_pass(git_repository_message(&_actual, _repo));
36 cl_assert_equal_s(expected, _actual);
37 git_buf_free(&_actual);
38
39 cl_git_pass(p_unlink(git_buf_cstr(&_path)));
40 cl_assert_equal_i(GIT_ENOTFOUND, git_repository_message(&_actual, _repo));
41 }