about summary refs log tree commit diff
path: root/t/t0041-usage.sh
diff options
context:
space:
mode:
authorVincent Ambo <Vincent Ambo>2020-01-11T23·36+0000
committerVincent Ambo <Vincent Ambo>2020-01-11T23·36+0000
commit1b593e1ea4d2af0f6444d9a7788d5d99abd6fde5 (patch)
treee3accb9beed5c4c1b5a05c99db71ab2841f0ed04 /t/t0041-usage.sh
Squashed 'third_party/git/' content from commit cb71568594
git-subtree-dir: third_party/git
git-subtree-split: cb715685942260375e1eb8153b0768a376e4ece7
Diffstat (limited to 't/t0041-usage.sh')
-rwxr-xr-xt/t0041-usage.sh107
1 files changed, 107 insertions, 0 deletions
diff --git a/t/t0041-usage.sh b/t/t0041-usage.sh
new file mode 100755
index 000000000000..5b927b76fe58
--- /dev/null
+++ b/t/t0041-usage.sh
@@ -0,0 +1,107 @@
+#!/bin/sh
+
+test_description='Test commands behavior when given invalid argument value'
+
+. ./test-lib.sh
+
+test_expect_success 'setup ' '
+	test_commit "v1.0"
+'
+
+test_expect_success 'tag --contains <existent_tag>' '
+	git tag --contains "v1.0" >actual 2>actual.err &&
+	grep "v1.0" actual &&
+	test_line_count = 0 actual.err
+'
+
+test_expect_success 'tag --contains <inexistent_tag>' '
+	test_must_fail git tag --contains "notag" >actual 2>actual.err &&
+	test_line_count = 0 actual &&
+	test_i18ngrep "error" actual.err &&
+	test_i18ngrep ! "usage" actual.err
+'
+
+test_expect_success 'tag --no-contains <existent_tag>' '
+	git tag --no-contains "v1.0" >actual 2>actual.err  &&
+	test_line_count = 0 actual &&
+	test_line_count = 0 actual.err
+'
+
+test_expect_success 'tag --no-contains <inexistent_tag>' '
+	test_must_fail git tag --no-contains "notag" >actual 2>actual.err &&
+	test_line_count = 0 actual &&
+	test_i18ngrep "error" actual.err &&
+	test_i18ngrep ! "usage" actual.err
+'
+
+test_expect_success 'tag usage error' '
+	test_must_fail git tag --noopt >actual 2>actual.err &&
+	test_line_count = 0 actual &&
+	test_i18ngrep "usage" actual.err
+'
+
+test_expect_success 'branch --contains <existent_commit>' '
+	git branch --contains "master" >actual 2>actual.err &&
+	test_i18ngrep "master" actual &&
+	test_line_count = 0 actual.err
+'
+
+test_expect_success 'branch --contains <inexistent_commit>' '
+	test_must_fail git branch --no-contains "nocommit" >actual 2>actual.err &&
+	test_line_count = 0 actual &&
+	test_i18ngrep "error" actual.err &&
+	test_i18ngrep ! "usage" actual.err
+'
+
+test_expect_success 'branch --no-contains <existent_commit>' '
+	git branch --no-contains "master" >actual 2>actual.err &&
+	test_line_count = 0 actual &&
+	test_line_count = 0 actual.err
+'
+
+test_expect_success 'branch --no-contains <inexistent_commit>' '
+	test_must_fail git branch --no-contains "nocommit" >actual 2>actual.err &&
+	test_line_count = 0 actual &&
+	test_i18ngrep "error" actual.err &&
+	test_i18ngrep ! "usage" actual.err
+'
+
+test_expect_success 'branch usage error' '
+	test_must_fail git branch --noopt >actual 2>actual.err &&
+	test_line_count = 0 actual &&
+	test_i18ngrep "usage" actual.err
+'
+
+test_expect_success 'for-each-ref --contains <existent_object>' '
+	git for-each-ref --contains "master" >actual 2>actual.err &&
+	test_line_count = 2 actual &&
+	test_line_count = 0 actual.err
+'
+
+test_expect_success 'for-each-ref --contains <inexistent_object>' '
+	test_must_fail git for-each-ref --no-contains "noobject" >actual 2>actual.err &&
+	test_line_count = 0 actual &&
+	test_i18ngrep "error" actual.err &&
+	test_i18ngrep ! "usage" actual.err
+'
+
+test_expect_success 'for-each-ref --no-contains <existent_object>' '
+	git for-each-ref --no-contains "master" >actual 2>actual.err &&
+	test_line_count = 0 actual &&
+	test_line_count = 0 actual.err
+'
+
+test_expect_success 'for-each-ref --no-contains <inexistent_object>' '
+	test_must_fail git for-each-ref --no-contains "noobject" >actual 2>actual.err &&
+	test_line_count = 0 actual &&
+	test_i18ngrep "error" actual.err &&
+	test_i18ngrep ! "usage" actual.err
+'
+
+test_expect_success 'for-each-ref usage error' '
+	test_must_fail git for-each-ref --noopt >actual 2>actual.err &&
+	test_line_count = 0 actual &&
+	test_i18ngrep "usage" actual.err
+'
+
+test_done