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