3 test_description
='Test advise_if_enabled functionality'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=trunk
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
11 test_expect_success
'advice should be printed when config variable is unset' '
12 cat >expect <<-\EOF &&
13 hint: This is a piece of advice
14 hint: Disable this message with "git config advice.nestedTag false"
16 test-tool advise "This is a piece of advice" 2>actual &&
17 test_cmp expect actual
20 test_expect_success
'advice should be printed when config variable is set to true' '
21 cat >expect <<-\EOF &&
22 hint: This is a piece of advice
24 test_config advice.nestedTag true &&
25 test-tool advise "This is a piece of advice" 2>actual &&
26 test_cmp expect actual
29 test_expect_success
'advice should not be printed when config variable is set to false' '
30 test_config advice.nestedTag false &&
31 test-tool advise "This is a piece of advice" 2>actual &&
32 test_must_be_empty actual
35 test_expect_success
'advice should not be printed when --no-advice is used' '
36 q_to_tab >expect <<-\EOF &&
44 nothing added to commit but untracked files present
47 test_when_finished "rm -fr advice-test" &&
48 git init advice-test &&
52 git --no-advice status
54 test_cmp expect actual
57 test_expect_success
'advice should not be printed when GIT_ADVICE is set to false' '
58 q_to_tab >expect <<-\EOF &&
66 nothing added to commit but untracked files present
69 test_when_finished "rm -fr advice-test" &&
70 git init advice-test &&
74 GIT_ADVICE=false git status
76 test_cmp expect actual
79 test_expect_success
'advice should be printed when GIT_ADVICE is set to true' '
80 q_to_tab >expect <<-\EOF &&
86 (use "git add <file>..." to include in what will be committed)
89 nothing added to commit but untracked files present (use "git add" to track)
92 test_when_finished "rm -fr advice-test" &&
93 git init advice-test &&
97 GIT_ADVICE=true git status
99 test_cmp expect actual