]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - usr.sbin/pw/tests/pw_usershow_test.sh
MFC r319026:
[FreeBSD/stable/10.git] / usr.sbin / pw / tests / pw_usershow_test.sh
1 # $FreeBSD$
2
3 # Import helper functions
4 . $(atf_get_srcdir)/helper_functions.shin
5
6 atf_test_case user_show_all
7 user_show_all_body() {
8         populate_etc_skel
9         atf_check -o not-empty ${PW} usershow -a
10 }
11
12 atf_test_case user_show_name
13 user_show_name_body() {
14         populate_etc_skel
15         atf_check -o not-empty ${PW} usershow root
16 }
17
18 atf_test_case user_show_nonexistent_name
19 user_show_nonexistent_name_body() {
20         populate_etc_skel
21
22         nonexistent_user=bogus
23         no_such_user_msg="pw: no such user \`$nonexistent_user'\n"
24
25         atf_check -e "inline:$no_such_user_msg" -s exit:67 ${PW} usershow \
26                 $nonexistent_user
27         atf_check -e "inline:$no_such_user_msg" -s exit:67 ${PW} usershow \
28                 -n $nonexistent_user
29 }
30
31 atf_test_case user_show_nonexistent_uid
32 user_show_nonexistent_uid_body() {
33         populate_etc_skel
34
35         nonexistent_uid=4242
36         no_such_uid_msg="pw: no such uid \`$nonexistent_uid'\n"
37
38         atf_check -e "inline:$no_such_uid_msg" -s exit:67 ${PW} usershow \
39                 $nonexistent_uid
40         atf_check -e "inline:$no_such_uid_msg" -s exit:67 ${PW} usershow \
41                 -u $nonexistent_uid
42 }
43
44 atf_test_case user_show_uid
45 user_show_uid_body() {
46         populate_etc_skel
47         atf_check -o not-empty ${PW} usershow -u 0
48 }
49
50 atf_init_test_cases() {
51         atf_add_test_case user_show_all
52         atf_add_test_case user_show_name
53         atf_add_test_case user_show_nonexistent_name
54         atf_add_test_case user_show_nonexistent_uid
55         atf_add_test_case user_show_uid
56 }