summaryrefslogtreecommitdiff
path: root/tests/odb
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-03-23 09:59:46 +0000
committerPatrick Steinhardt <ps@pks.im>2018-03-23 10:06:22 +0000
commita52b4c51c0a7de341f5b2cef48ac6d7c8b9476e1 (patch)
treeaab5ab0ee9bfaeae3b6c9f36b1032aa4bb59e7fd /tests/odb
parent904307af38a717c6dc4fd72855914e60b1930d2d (diff)
downloadlibgit2-a52b4c51c0a7de341f5b2cef48ac6d7c8b9476e1.tar.gz
odb: fix writing to fake write streams
In commit 7ec7aa4a7 (odb: assert on logic errors when writing objects, 2018-02-01), the check for whether we are trying to overflowing the fake stream buffer was changed from returning an error to raising an assert. The conversion forgot though that the logic around `assert`s are basically inverted. Previously, if the statement stream->written + len > steram->size evaluated to true, we would return a `-1`. Now we are asserting that this statement is true, and in case it is not we will raise an error. So the conversion to the `assert` in fact changed the behaviour to the complete opposite intention. Fix the assert by inverting its condition again and add a regression test.
Diffstat (limited to 'tests/odb')
-rw-r--r--tests/odb/backend/mempack.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/odb/backend/mempack.c b/tests/odb/backend/mempack.c
index 46c685c38..624f0e604 100644
--- a/tests/odb/backend/mempack.c
+++ b/tests/odb/backend/mempack.c
@@ -50,3 +50,11 @@ void test_odb_backend_mempack__exists_with_existing_objects_succeeds(void)
cl_git_pass(git_odb_write(&_oid, _odb, data, strlen(data) + 1, GIT_OBJ_BLOB));
cl_assert(git_odb_exists(_odb, &_oid) == 1);
}
+
+void test_odb_backend_mempack__blob_create_frombuffer_succeeds(void)
+{
+ const char *data = "data";
+
+ cl_git_pass(git_blob_create_frombuffer(&_oid, _repo, data, strlen(data) + 1));
+ cl_assert(git_odb_exists(_odb, &_oid) == 1);
+}