]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - usr.sbin/pw/tests/pw_groupshow_test.sh
MFC r319026:
[FreeBSD/stable/10.git] / usr.sbin / pw / tests / pw_groupshow_test.sh
1 # $FreeBSD$
2
3 # Import helper functions
4 . $(atf_get_srcdir)/helper_functions.shin
5
6 atf_test_case group_show_all
7 group_show_all_body() {
8         populate_etc_skel
9         atf_check -o not-empty ${PW} groupshow -a
10 }
11
12 atf_test_case group_show_gid
13 group_show_gid_body() {
14         populate_etc_skel
15         atf_check -o not-empty ${PW} groupshow -g 0
16 }
17
18 atf_test_case group_show_name
19 group_show_name_body() {
20         populate_etc_skel
21         atf_check -o not-empty ${PW} groupshow wheel
22 }
23
24 atf_test_case group_show_nonexistent_gid
25 group_show_nonexistent_gid_body() {
26         populate_etc_skel
27
28         nonexistent_gid=4242
29         no_such_name_msg="pw: unknown gid \`$nonexistent_gid'\n"
30
31         atf_check -e "inline:$no_such_name_msg" -s exit:65 ${PW} groupshow \
32                 $nonexistent_gid
33         atf_check -e "inline:$no_such_name_msg" -s exit:65 ${PW} groupshow \
34                 -g $nonexistent_gid
35 }
36
37 atf_test_case group_show_nonexistent_name
38 group_show_nonexistent_name_body() {
39         populate_etc_skel
40
41         nonexistent_name=bogus
42         no_such_name_msg="pw: unknown group \`$nonexistent_name'\n"
43
44         atf_check -e "inline:$no_such_name_msg" -s exit:65 ${PW} groupshow \
45                 $nonexistent_name
46         atf_check -e "inline:$no_such_name_msg" -s exit:65 ${PW} groupshow \
47                 -n $nonexistent_name
48 }
49
50 atf_init_test_cases() {
51         atf_add_test_case group_show_all
52         atf_add_test_case group_show_gid
53         atf_add_test_case group_show_name
54         atf_add_test_case group_show_nonexistent_gid
55         atf_add_test_case group_show_nonexistent_name
56 }