diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-02-04 21:40:22 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-02-05 12:07:56 +0100 |
commit | d6236cf662ebd4ba8ef4902c81a19bbfd92847f9 (patch) | |
tree | 604854231cebd63cd1e87a034764577726d7e168 | |
parent | 1202c7eaa6f0fd6407bc386881edd686771fc0f4 (diff) | |
download | libgit2-d6236cf662ebd4ba8ef4902c81a19bbfd92847f9.tar.gz |
refs: add tests for conditional updates
-rw-r--r-- | tests/refs/races.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/refs/races.c b/tests/refs/races.c new file mode 100644 index 000000000..4d24896f1 --- /dev/null +++ b/tests/refs/races.c @@ -0,0 +1,42 @@ +#include "clar_libgit2.h" + +#include "repository.h" +#include "git2/reflog.h" +#include "reflog.h" +#include "ref_helpers.h" + +static const char *commit_id = "099fabac3a9ea935598528c27f866e34089c2eff"; +static const char *refname = "refs/heads/master"; +static const char *other_commit_id = "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"; + +static git_repository *g_repo; + +void test_refs_races__initialize(void) +{ + g_repo = cl_git_sandbox_init("testrepo"); +} + +void test_refs_races__cleanup(void) +{ + cl_git_sandbox_cleanup(); +} + +void test_refs_races__create_matching(void) +{ + int error; + git_reference *ref, *ref2, *ref3; + git_oid id, other_id; + + git_oid_fromstr(&id, commit_id); + git_oid_fromstr(&other_id, other_commit_id); + + cl_git_fail_with(GIT_EMODIFIED, git_reference_create_matching(&ref, g_repo, refname, &other_id, 1, NULL, NULL, &other_id)); + + cl_git_pass(git_reference_lookup(&ref, g_repo, refname)); + cl_git_pass(git_reference_create_matching(&ref2, g_repo, refname, &other_id, 1, NULL, NULL, &id)); + cl_git_fail_with(GIT_EMODIFIED, git_reference_set_target(&ref3, ref, &other_id, NULL, NULL)); + + git_reference_free(ref); + git_reference_free(ref2); + git_reference_free(ref3); +} |