Add tests for for-each-ref which utilizes the ref-filter APIs.

Based-on-patch-by: Jeff King <p...@peff.net>
Mentored-by: Christian Couder <christian.cou...@gmail.com>
Mentored-by: Matthieu Moy <matthieu....@grenoble-inp.fr>
Signed-off-by: Karthik Nayak <karthik....@gmail.com>
---
 t/t6301-for-each-ref-filter.sh | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 t/t6301-for-each-ref-filter.sh

diff --git a/t/t6301-for-each-ref-filter.sh b/t/t6301-for-each-ref-filter.sh
new file mode 100644
index 0000000..5bd49b3
--- /dev/null
+++ b/t/t6301-for-each-ref-filter.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+test_description='test for-each-refs usage of ref-filter APIs'
+
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-gpg.sh
+
+test_expect_success 'setup some history and refs' '
+       test_commit one &&
+       test_commit two &&
+       test_commit three &&
+       git checkout -b side &&
+       test_commit four &&
+       git checkout master &&
+       git update-ref refs/odd/spot master
+'
+test_expect_success 'filtering by leading name' '
+       cat >expect <<-\EOF &&
+       refs/heads/master
+       refs/heads/side
+       EOF
+       git for-each-ref --format="%(refname)" refs/heads >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'filtering with fnmatch' '
+       cat >expect <<-\EOF &&
+       refs/tags/three
+       refs/tags/two
+       EOF
+       git for-each-ref --format="%(refname)" refs/tags/t* >actual &&
+       test_cmp expect actual
+'
+
+test_done
-- 
2.4.3.435.g2403634.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to