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