Add unit tests for Commit parsing
[libgit2.git] / tests / t0201-existsloose.c
blob0c7fda8e41f67823610884815c71cf47c6dde496
1 #include "test_lib.h"
2 #include "test_helpers.h"
3 #include <git/odb.h>
5 static char *odb_dir = "test-objects";
7 /* one == 8b137891791fe96927ad78e64b0aad7bded08bdc */
8 static unsigned char one_bytes[] = {
9 0x31, 0x78, 0x9c, 0xe3, 0x02, 0x00, 0x00, 0x0b,
10 0x00, 0x0b,
13 static unsigned char one_data[] = {
14 0x0a,
17 static object_data one = {
18 one_bytes,
19 sizeof(one_bytes),
20 "8b137891791fe96927ad78e64b0aad7bded08bdc",
21 "blob",
22 "test-objects/8b",
23 "test-objects/8b/137891791fe96927ad78e64b0aad7bded08bdc",
24 one_data,
25 sizeof(one_data),
29 BEGIN_TEST(exists_loose_one)
30 git_odb *db;
31 git_oid id, id2;
33 must_pass(write_object_files(odb_dir, &one));
34 must_pass(git_odb_open(&db, odb_dir));
35 must_pass(git_oid_mkstr(&id, one.id));
37 must_be_true(git_odb_exists(db, &id));
39 /* Test for a non-existant object */
40 must_pass(git_oid_mkstr(&id2, "8b137891791fe96927ad78e64b0aad7bded08baa"));
41 must_be_true(0 == git_odb_exists(db, &id2));
43 git_odb_close(db);
44 must_pass(remove_object_files(odb_dir, &one));
45 END_TEST