summaryrefslogtreecommitdiff
path: root/tests/object
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-11-19 18:42:29 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2014-11-22 18:55:22 +0100
commit753e17b0f518c2510848a9dd73cc45e4c6df1a8a (patch)
tree39b27d69fa709024ba8b786c04bc66264d9cd97b /tests/object
parent4d86caec599ab760b523a026040bc4f40f8338c9 (diff)
downloadlibgit2-cmn/peeling-errors.tar.gz
peel: reject bad queries with EINVALIDSPECcmn/peeling-errors
There are some combination of objects and target types which we know cannot be fulfilled. Return EINVALIDSPEC for those to signify that there is a mismatch in the user-provided data and what the object model is capable of satisfying. If we start at a tag and in the course of peeling find out that we cannot reach a particular type, we return EPEEL.
Diffstat (limited to 'tests/object')
-rw-r--r--tests/object/peel.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/tests/object/peel.c b/tests/object/peel.c
index 6310388c4..344885f1d 100644
--- a/tests/object/peel.c
+++ b/tests/object/peel.c
@@ -63,28 +63,47 @@ void test_object_peel__peeling_an_object_into_its_own_type_returns_another_insta
"0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_BLOB);
}
-void test_object_peel__can_peel_a_tag(void)
+void test_object_peel__tag(void)
{
assert_peel("7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ_COMMIT,
"e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_COMMIT);
assert_peel("7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ_TREE,
"53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE);
+ assert_peel_error(GIT_EPEEL, "7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ_BLOB);
+ assert_peel("7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ_ANY,
+ "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_COMMIT);
}
-void test_object_peel__can_peel_a_commit(void)
+void test_object_peel__commit(void)
{
+ assert_peel_error(GIT_EINVALIDSPEC, "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_BLOB);
assert_peel("e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_TREE,
- "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE);
+ "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE);
+ assert_peel("e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_COMMIT,
+ "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_COMMIT);
+ assert_peel_error(GIT_EINVALIDSPEC, "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_TAG);
+ assert_peel("e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_ANY,
+ "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE);
}
-void test_object_peel__cannot_peel_a_tree(void)
+void test_object_peel__tree(void)
{
- assert_peel_error(GIT_EAMBIGUOUS, "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_BLOB);
+ assert_peel_error(GIT_EINVALIDSPEC, "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_BLOB);
+ assert_peel("53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE,
+ "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE);
+ assert_peel_error(GIT_EINVALIDSPEC, "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_COMMIT);
+ assert_peel_error(GIT_EINVALIDSPEC, "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TAG);
+ assert_peel_error(GIT_EINVALIDSPEC, "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_ANY);
}
-void test_object_peel__cannot_peel_a_blob(void)
+void test_object_peel__blob(void)
{
- assert_peel_error(GIT_ENOTFOUND, "0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_COMMIT);
+ assert_peel("0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_BLOB,
+ "0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_BLOB);
+ assert_peel_error(GIT_EINVALIDSPEC, "0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_TREE);
+ assert_peel_error(GIT_EINVALIDSPEC, "0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_COMMIT);
+ assert_peel_error(GIT_EINVALIDSPEC, "0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_TAG);
+ assert_peel_error(GIT_EINVALIDSPEC, "0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_ANY);
}
void test_object_peel__target_any_object_for_type_change(void)
@@ -96,10 +115,4 @@ void test_object_peel__target_any_object_for_type_change(void)
/* commit to tree */
assert_peel("e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_ANY,
"53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE);
-
- /* fail to peel tree */
- assert_peel_error(GIT_EAMBIGUOUS, "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_ANY);
-
- /* fail to peel blob */
- assert_peel_error(GIT_ENOTFOUND, "0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_ANY);
}