pw_usershow_test.sh revision 321163
1# $FreeBSD: stable/10/usr.sbin/pw/tests/pw_usershow_test.sh 321163 2017-07-18 18:48:25Z ngie $
2
3# Import helper functions
4. $(atf_get_srcdir)/helper_functions.shin
5
6atf_test_case user_show_all
7user_show_all_body() {
8	populate_etc_skel
9	atf_check -o not-empty ${PW} usershow -a
10}
11
12atf_test_case user_show_name
13user_show_name_body() {
14	populate_etc_skel
15	atf_check -o not-empty ${PW} usershow root
16}
17
18atf_test_case user_show_nonexistent_name
19user_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
31atf_test_case user_show_nonexistent_uid
32user_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
44atf_test_case user_show_uid
45user_show_uid_body() {
46	populate_etc_skel
47	atf_check -o not-empty ${PW} usershow -u 0
48}
49
50atf_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}
57