Skip to content

Commit d3ab1a5

Browse files
avargitster
authored andcommitted
reflog tests: add missing "git reflog exists" tests
There were a few "git reflog exists" tests scattered over the test suite, but let's consolidate the testing of the main functionality into a new test file. This makes it easier to run just these tests during development. To do that amend and extend an existing test added in afcb2e7 (git-reflog: add exists command, 2015-07-21). Let's use "test_must_fail" instead of "!" (in case it segfaults), and test for basic usage, an unknown option etc. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5f9b64a commit d3ab1a5

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

t/t1411-reflog-show.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,4 @@ test_expect_success 'git log -g -p shows diffs vs. parents' '
169169
test_cmp expect actual
170170
'
171171

172-
test_expect_success 'reflog exists works' '
173-
git reflog exists refs/heads/main &&
174-
! git reflog exists refs/heads/nonexistent
175-
'
176-
177172
test_done

t/t1418-reflog-exists.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
3+
test_description='Test reflog display routines'
4+
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5+
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6+
7+
. ./test-lib.sh
8+
9+
test_expect_success 'setup' '
10+
test_commit A
11+
'
12+
13+
test_expect_success 'usage' '
14+
test_expect_code 129 git reflog exists &&
15+
test_expect_code 129 git reflog exists -h
16+
'
17+
18+
test_expect_success 'usage: unknown option' '
19+
test_expect_code 129 git reflog exists --unknown-option
20+
'
21+
22+
test_expect_success 'reflog exists works' '
23+
git reflog exists refs/heads/main &&
24+
test_must_fail git reflog exists refs/heads/nonexistent
25+
'
26+
27+
test_expect_success 'reflog exists works with a "--" delimiter' '
28+
git reflog exists -- refs/heads/main &&
29+
test_must_fail git reflog exists -- refs/heads/nonexistent
30+
'
31+
32+
test_done

0 commit comments

Comments
 (0)