]>
git.proxmox.com Git - libgit2.git/blob - tests/odb/foreach.c
1 #include "clar_libgit2.h"
3 #include "git2/odb_backend.h"
7 static git_repository
*_repo
;
10 void test_odb_foreach__cleanup(void)
13 git_repository_free(_repo
);
19 static int foreach_cb(const git_oid
*oid
, void *data
)
30 * $ git --git-dir tests/resources/testrepo.git count-objects --verbose
39 void test_odb_foreach__foreach(void)
41 cl_git_pass(git_repository_open(&_repo
, cl_fixture("testrepo.git")));
42 git_repository_odb(&_odb
, _repo
);
44 cl_git_pass(git_odb_foreach(_odb
, foreach_cb
, NULL
));
45 cl_assert_equal_i(47 + 1640, nobj
); /* count + in-pack */
48 void test_odb_foreach__one_pack(void)
50 git_odb_backend
*backend
= NULL
;
52 cl_git_pass(git_odb_new(&_odb
));
53 cl_git_pass(git_odb_backend_one_pack(&backend
, cl_fixture("testrepo.git/objects/pack/pack-a81e489679b7d3418f9ab594bda8ceb37dd4c695.idx")));
54 cl_git_pass(git_odb_add_backend(_odb
, backend
, 1));
58 cl_git_pass(git_odb_foreach(_odb
, foreach_cb
, NULL
));
59 cl_assert(nobj
== 1628);
62 static int foreach_stop_cb(const git_oid
*oid
, void *data
)
69 return (nobj
== 1000);
72 void test_odb_foreach__interrupt_foreach(void)
75 cl_git_pass(git_repository_open(&_repo
, cl_fixture("testrepo.git")));
76 git_repository_odb(&_odb
, _repo
);
78 cl_assert_equal_i(GIT_EUSER
, git_odb_foreach(_odb
, foreach_stop_cb
, NULL
));
79 cl_assert(nobj
== 1000);