pw_groupshow_test.sh revision 321164
1# $FreeBSD: stable/11/usr.sbin/pw/tests/pw_groupshow_test.sh 321164 2017-07-18 18:48:58Z ngie $
2
3# Import helper functions
4. $(atf_get_srcdir)/helper_functions.shin
5
6atf_test_case group_show_all
7group_show_all_body() {
8	populate_etc_skel
9	atf_check -o not-empty ${PW} groupshow -a
10}
11
12atf_test_case group_show_gid
13group_show_gid_body() {
14	populate_etc_skel
15	atf_check -o not-empty ${PW} groupshow -g 0
16}
17
18atf_test_case group_show_name
19group_show_name_body() {
20	populate_etc_skel
21	atf_check -o not-empty ${PW} groupshow wheel
22}
23
24atf_test_case group_show_nonexistent_gid
25group_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
37atf_test_case group_show_nonexistent_name
38group_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
50atf_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}
57