mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-05 22:35:51 +00:00

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.
22 lines
360 B
C
22 lines
360 B
C
#include "git2/sys/odb_backend.h"
|
|
|
|
typedef struct {
|
|
const char *oid;
|
|
const char *content;
|
|
} fake_object;
|
|
|
|
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,
|
|
const fake_object *objects);
|