diff options
| author | Patrick Steinhardt <ps@pks.im> | 2017-06-12 15:43:56 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2017-06-12 17:24:53 +0200 |
| commit | 6e010bb126360d084b1c38056728c7fd3286a443 (patch) | |
| tree | 799692f140211ac6f03cbe1af0a0adab732eb192 /tests/odb/backend/backend_helpers.h | |
| parent | 369cb45fc300e6a7951c5c9a65bbf0c0f6f32f16 (diff) | |
| download | libgit2-6e010bb126360d084b1c38056728c7fd3286a443.tar.gz | |
tests: odb: allow passing fake objects to the fake backend
Right now, the fake backend is quite restrained in the way how it
works: we pass it an OID which it is to return later as well as an error
code we want it to return. While this is sufficient for existing tests,
we can make the fake backend a little bit more generic in order to allow
us testing for additional scenarios.
To do so, we change the backend to not accept an error code and OID
which it is to return for queries, but instead a simple array of OIDs
with their respective blob contents. On each query, the fake backend
simply iterates through this array and returns the first matching
object.
Diffstat (limited to 'tests/odb/backend/backend_helpers.h')
| -rw-r--r-- | tests/odb/backend/backend_helpers.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/odb/backend/backend_helpers.h b/tests/odb/backend/backend_helpers.h index 04bd844b2..6cc1ce90d 100644 --- a/tests/odb/backend/backend_helpers.h +++ b/tests/odb/backend/backend_helpers.h @@ -1,18 +1,21 @@ #include "git2/sys/odb_backend.h" typedef struct { - git_odb_backend parent; + const char *oid; + const char *content; +} fake_object; - git_error_code error_code; - git_oid oid; +typedef struct { + git_odb_backend parent; int exists_calls; int read_calls; int read_header_calls; int read_prefix_calls; + + const fake_object *objects; } fake_backend; int build_fake_backend( git_odb_backend **out, - git_error_code error_code, - const git_oid *oid); + const fake_object *objects); |
