summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorschu <schu-github@schulog.org>2011-07-26 11:17:32 +0200
committerVicent Marti <tanoku@gmail.com>2011-11-06 03:15:22 +0100
commit4fd89fa0392967fabb905c7f4001cd4834f11dbd (patch)
treea0d908231730536d0e87e085d38c343644591425 /tests
parenta46ec45746f965f2895098e058979225d92d66e5 (diff)
downloadlibgit2-4fd89fa0392967fabb905c7f4001cd4834f11dbd.tar.gz
refs: add test case checking "immutable" references
Signed-off-by: schu <schu-github@schulog.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/t10-refs.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/t10-refs.c b/tests/t10-refs.c
index cfedff0a5..298aaa07f 100644
--- a/tests/t10-refs.c
+++ b/tests/t10-refs.c
@@ -808,6 +808,37 @@ BEGIN_TEST(delete0, "deleting a ref which is both packed and loose should remove
close_temp_repo(repo);
END_TEST
+BEGIN_TEST(delete1, "can delete a just packed reference")
+ git_reference *ref;
+ git_repository *repo;
+ git_oid id;
+ const char *new_ref = "refs/heads/new_ref";
+
+ git_oid_fromstr(&id, current_master_tip);
+
+ must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
+
+ /* Create and write the new object id reference */
+ must_pass(git_reference_create_oid(&ref, repo, new_ref, &id, 0));
+
+ /* Lookup the reference */
+ must_pass(git_reference_lookup(&ref, repo, new_ref));
+
+ /* Ensure it's a loose reference */
+ must_be_true(git_reference_is_packed(ref) == 0);
+
+ /* Pack all existing references */
+ must_pass(git_reference_packall(repo));
+
+ /* Ensure it's a packed reference */
+ must_be_true(git_reference_is_packed(ref) == 1);
+
+ /* This should pass */
+ must_pass(git_reference_delete(ref));
+
+ close_temp_repo(repo);
+END_TEST
+
static int ensure_refname_normalized(int is_oid_ref, const char *input_refname, const char *expected_refname)
{
int error = GIT_SUCCESS;
@@ -1172,6 +1203,7 @@ BEGIN_SUITE(refs)
ADD_TEST(rename9);
ADD_TEST(delete0);
+ ADD_TEST(delete1);
ADD_TEST(list0);
ADD_TEST(list1);