@@ -12,31 +12,28 @@ teardown() {
1212}
1313
1414@test " $SUITE : use default selection options" {
15- run " $_GO_SCRIPT " demo-core select-option <<< $' 1\n 1 \n 2\n 2 \n '
15+ run " $_GO_SCRIPT " demo-core select-option <<< $' 1\n Yes \n 2\n No '
1616 assert_success
1717 split_bats_output_into_lines
18+
19+ local select_affirmative=' Would you like to select another option? [Y/n] '
20+ select_affirmative+=' Please select one of the following options:'
21+
1822 assert_lines_equal ' Please select one of the following options:' \
1923 ' 1) Hello, World!' \
2024 ' 2) Goodbye, World!' \
2125 " ${PS3} You selected: \" Hello, World!\" " \
2226 ' ' \
23- ' Would you like to select another option?' \
24- ' 1) Yes' \
25- ' 2) No' \
26- " ${PS3} " \
27- ' Please select one of the following options:' \
27+ " ${select_affirmative} " \
2828 ' 1) Hello, World!' \
2929 ' 2) Goodbye, World!' \
3030 " ${PS3} You selected: \" Goodbye, World!\" " \
3131 ' ' \
32- ' Would you like to select another option?' \
33- ' 1) Yes' \
34- ' 2) No' \
35- " ${PS3} Exiting..."
32+ ' Would you like to select another option? [Y/n] Exiting...'
3633}
3734
3835@test " $SUITE : use user-provided selection options" {
39- run " $_GO_SCRIPT " demo-core select-option foo bar baz <<< $' 2\n 2 \n '
36+ run " $_GO_SCRIPT " demo-core select-option foo bar baz <<< $' 2\n No '
4037 assert_success
4138 split_bats_output_into_lines
4239 assert_lines_equal ' Please select one of the following options:' \
@@ -45,30 +42,21 @@ teardown() {
4542 ' 3) baz' \
4643 " ${PS3} You selected: \" bar\" " \
4744 ' ' \
48- ' Would you like to select another option?' \
49- ' 1) Yes' \
50- ' 2) No' \
51- " ${PS3} Exiting..."
45+ ' Would you like to select another option? [Y/n] Exiting...'
5246}
5347
54- @test " $SUITE : exit both prompts on empty input" {
48+ @test " $SUITE : exit prompt and program on empty input terminated by EOF " {
5549 mkdir " $TEST_GO_ROOTDIR "
5650 printf ' ' > " $TEST_GO_ROOTDIR /input.txt"
5751 run " $_GO_SCRIPT " demo-core select-option foo bar baz \
5852 < " $TEST_GO_ROOTDIR /input.txt"
5953
60- assert_success
54+ assert_failure
6155 split_bats_output_into_lines
6256 assert_lines_equal ' Please select one of the following options:' \
6357 ' 1) foo' \
6458 ' 2) bar' \
6559 ' 3) baz' \
6660 " ${PS3} " \
67- ' You declined to select an option.' \
68- ' ' \
69- ' Would you like to select another option?' \
70- ' 1) Yes' \
71- ' 2) No' \
72- " ${PS3} " \
7361 ' You declined to select an option. Exiting...'
7462}
0 commit comments