Blame tests/repo/message.c

Packit Service 20376f
#include "clar_libgit2.h"
Packit Service 20376f
#include "buffer.h"
Packit Service 20376f
#include "refs.h"
Packit Service 20376f
#include "posix.h"
Packit Service 20376f
Packit Service 20376f
static git_repository *_repo;
Packit Service 20376f
Packit Service 20376f
void test_repo_message__initialize(void)
Packit Service 20376f
{
Packit Service 20376f
	_repo = cl_git_sandbox_init("testrepo.git");
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_repo_message__cleanup(void)
Packit Service 20376f
{
Packit Service 20376f
	cl_git_sandbox_cleanup();
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_repo_message__none(void)
Packit Service 20376f
{
Packit Service 20376f
	git_buf actual = GIT_BUF_INIT;
Packit Service 20376f
	cl_assert_equal_i(GIT_ENOTFOUND, git_repository_message(&actual, _repo));
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_repo_message__message(void)
Packit Service 20376f
{
Packit Service 20376f
	git_buf path = GIT_BUF_INIT, actual = GIT_BUF_INIT;
Packit Service 20376f
	const char expected[] = "Test\n\nThis is a test of the emergency broadcast system\n";
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_buf_joinpath(&path, git_repository_path(_repo), "MERGE_MSG"));
Packit Service 20376f
	cl_git_mkfile(git_buf_cstr(&path), expected);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_repository_message(&actual, _repo));
Packit Service 20376f
	cl_assert_equal_s(expected, git_buf_cstr(&actual));
Packit Service 20376f
	git_buf_free(&actual);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(p_unlink(git_buf_cstr(&path)));
Packit Service 20376f
	cl_assert_equal_i(GIT_ENOTFOUND, git_repository_message(&actual, _repo));
Packit Service 20376f
	git_buf_free(&path);
Packit Service 20376f
}