odb_loose: test read_header explicitly
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
diff --git a/tests/odb/loose.c b/tests/odb/loose.c
index 2207128..83d0807 100644
--- a/tests/odb/loose.c
+++ b/tests/odb/loose.c
@@ -55,6 +55,25 @@ static void test_read_object(object_data *data)
git_odb_free(odb);
}
+static void test_read_header(object_data *data)
+{
+ git_oid id;
+ git_odb *odb;
+ size_t len;
+ git_otype type;
+
+ write_object_files(data);
+
+ cl_git_pass(git_odb_open(&odb, "test-objects"));
+ cl_git_pass(git_oid_fromstr(&id, data->id));
+ cl_git_pass(git_odb_read_header(&len, &type, odb, &id));
+
+ cl_assert_equal_sz(data->dlen, len);
+ cl_assert_equal_i(git_object_string2type(data->type), type);
+
+ git_odb_free(odb);
+}
+
static void test_readstream_object(object_data *data, size_t blocksize)
{
git_oid id;
@@ -157,6 +176,17 @@ void test_odb_loose__streaming_reads(void)
}
}
+void test_odb_loose__read_header(void)
+{
+ test_read_header(&commit);
+ test_read_header(&tree);
+ test_read_header(&tag);
+ test_read_header(&zero);
+ test_read_header(&one);
+ test_read_header(&two);
+ test_read_header(&some);
+}
+
void test_write_object_permission(
mode_t dir_mode, mode_t file_mode,
mode_t expected_dir_mode, mode_t expected_file_mode)