|
Packit Service |
20376f |
#include "clar_libgit2.h"
|
|
Packit Service |
20376f |
#include "git2/odb_backend.h"
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
static git_repository *repo;
|
|
Packit Service |
20376f |
static git_odb *odb;
|
|
Packit Service |
20376f |
static git_odb_stream *stream;
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
void test_odb_streamwrite__initialize(void)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
repo = cl_git_sandbox_init("testrepo.git");
|
|
Packit Service |
20376f |
cl_git_pass(git_repository_odb(&odb, repo));
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
cl_git_pass(git_odb_open_wstream(&stream, odb, 14, GIT_OBJ_BLOB));
|
|
Packit Service |
20376f |
cl_assert_equal_sz(14, stream->declared_size);
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
void test_odb_streamwrite__cleanup(void)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
git_odb_stream_free(stream);
|
|
Packit Service |
20376f |
git_odb_free(odb);
|
|
Packit Service |
20376f |
cl_git_sandbox_cleanup();
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
void test_odb_streamwrite__can_accept_chunks(void)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
git_oid oid;
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
cl_git_pass(git_odb_stream_write(stream, "deadbeef", 8));
|
|
Packit Service |
20376f |
cl_assert_equal_sz(8, stream->received_bytes);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
cl_git_pass(git_odb_stream_write(stream, "deadbeef", 6));
|
|
Packit Service |
20376f |
cl_assert_equal_sz(8 + 6, stream->received_bytes);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
cl_git_pass(git_odb_stream_finalize_write(&oid, stream));
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
void test_odb_streamwrite__can_detect_missing_bytes(void)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
git_oid oid;
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
cl_git_pass(git_odb_stream_write(stream, "deadbeef", 8));
|
|
Packit Service |
20376f |
cl_assert_equal_sz(8, stream->received_bytes);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
cl_git_pass(git_odb_stream_write(stream, "deadbeef", 4));
|
|
Packit Service |
20376f |
cl_assert_equal_sz(8 + 4, stream->received_bytes);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
cl_git_fail(git_odb_stream_finalize_write(&oid, stream));
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
void test_odb_streamwrite__can_detect_additional_bytes(void)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
cl_git_pass(git_odb_stream_write(stream, "deadbeef", 8));
|
|
Packit Service |
20376f |
cl_assert_equal_sz(8, stream->received_bytes);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
cl_git_fail(git_odb_stream_write(stream, "deadbeef", 7));
|
|
Packit Service |
20376f |
}
|