]> git.proxmox.com Git - libgit2.git/blob - tests/online/push_util.h
5f669feaf0c24509d08826eb114f7c613241a2bf
[libgit2.git] / tests / online / push_util.h
1 #ifndef INCLUDE_cl_push_util_h__
2 #define INCLUDE_cl_push_util_h__
3
4 #include "git2/oid.h"
5
6 /* Constant for zero oid */
7 extern const git_oid OID_ZERO;
8
9 /**
10 * Macro for initializing git_remote_callbacks to use test helpers that
11 * record data in a record_callbacks_data instance.
12 * @param data pointer to a record_callbacks_data instance
13 */
14 #define RECORD_CALLBACKS_INIT(data) \
15 { GIT_REMOTE_CALLBACKS_VERSION, NULL, NULL, cred_acquire_cb, NULL, NULL, record_update_tips_cb, NULL, NULL, NULL, NULL, NULL, NULL, data, NULL }
16
17 typedef struct {
18 char *name;
19 git_oid old_oid;
20 git_oid new_oid;
21 } updated_tip;
22
23 typedef struct {
24 git_vector updated_tips;
25 git_vector statuses;
26 int pack_progress_calls;
27 int transfer_progress_calls;
28 } record_callbacks_data;
29
30 typedef struct {
31 const char *name;
32 const git_oid *oid;
33 } expected_ref;
34
35 /* the results of a push status. when used for expected values, msg may be NULL
36 * to indicate that it should not be matched. */
37 typedef struct {
38 char *ref;
39 int success;
40 char *msg;
41 } push_status;
42
43
44 void updated_tip_free(updated_tip *t);
45
46 void record_callbacks_data_clear(record_callbacks_data *data);
47
48 /**
49 * Callback for git_remote_update_tips that records updates
50 *
51 * @param data (git_vector *) of updated_tip instances
52 */
53 int record_update_tips_cb(const char *refname, const git_oid *a, const git_oid *b, void *data);
54
55 /**
56 * Create a set of refspecs that deletes each of the inputs
57 *
58 * @param out the vector in which to store the refspecs
59 * @param heads the remote heads
60 * @param heads_len the size of the array
61 */
62 int create_deletion_refspecs(git_vector *out, const git_remote_head **heads, size_t heads_len);
63
64 /**
65 * Callback for git_remote_list that adds refspecs to vector
66 *
67 * @param head a ref on the remote
68 * @param payload (git_vector *) of git_remote_head instances
69 */
70 int record_ref_cb(git_remote_head *head, void *payload);
71
72 /**
73 * Verifies that refs on remote stored by record_ref_cb match the expected
74 * names, oids, and order.
75 *
76 * @param actual_refs actual refs in the remote
77 * @param actual_refs_len length of actual_refs
78 * @param expected_refs expected remote refs
79 * @param expected_refs_len length of expected_refs
80 */
81 void verify_remote_refs(const git_remote_head *actual_refs[], size_t actual_refs_len, const expected_ref expected_refs[], size_t expected_refs_len);
82
83 #endif /* INCLUDE_cl_push_util_h__ */