summaryrefslogtreecommitdiffstats
path: root/pw/tests/pw_usershow_test.sh
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2017-05-28 02:15:57 +0000
committerEnji Cooper <ngie@FreeBSD.org>2017-05-28 02:15:57 +0000
commitcc6a6ed4749dd4cc06857b7239a8dbb8098e4461 (patch)
tree988d8b6c6f09f9320d18cc462f2f8d499c8f869e /pw/tests/pw_usershow_test.sh
parentf03b79738ca650b944ae041581b20008076d436c (diff)
downloadpw-darwin-cc6a6ed4749dd4cc06857b7239a8dbb8098e4461.tar.gz
pw-darwin-cc6a6ed4749dd4cc06857b7239a8dbb8098e4461.tar.zst
pw-darwin-cc6a6ed4749dd4cc06857b7239a8dbb8098e4461.zip
pw: add some basic testcases for groupshow and usershow
- groupshow: test out -a/-g/-n . - usershow: test out -a/-n/-u . MFC after: 1 week Sponsored by: Dell EMC Isilon
Diffstat (limited to 'pw/tests/pw_usershow_test.sh')
-rwxr-xr-xpw/tests/pw_usershow_test.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/pw/tests/pw_usershow_test.sh b/pw/tests/pw_usershow_test.sh
new file mode 100755
index 0000000..5305979
--- /dev/null
+++ b/pw/tests/pw_usershow_test.sh
@@ -0,0 +1,56 @@
+# $FreeBSD$
+
+# Import helper functions
+. $(atf_get_srcdir)/helper_functions.shin
+
+atf_test_case user_show_all
+user_show_all_body() {
+ populate_etc_skel
+ atf_check -o not-empty ${PW} usershow -a
+}
+
+atf_test_case user_show_name
+user_show_name_body() {
+ populate_etc_skel
+ atf_check -o not-empty ${PW} usershow root
+}
+
+atf_test_case user_show_nonexistent_name
+user_show_nonexistent_name_body() {
+ populate_etc_skel
+
+ nonexistent_user=bogus
+ no_such_user_msg="pw: no such user \`$nonexistent_user'\n"
+
+ atf_check -e "inline:$no_such_user_msg" -s exit:67 ${PW} usershow \
+ $nonexistent_user
+ atf_check -e "inline:$no_such_user_msg" -s exit:67 ${PW} usershow \
+ -n $nonexistent_user
+}
+
+atf_test_case user_show_nonexistent_uid
+user_show_nonexistent_uid_body() {
+ populate_etc_skel
+
+ nonexistent_uid=4242
+ no_such_uid_msg="pw: no such uid \`$nonexistent_uid'\n"
+
+ atf_check -e "inline:$no_such_uid_msg" -s exit:67 ${PW} usershow \
+ $nonexistent_uid
+ atf_check -e "inline:$no_such_uid_msg" -s exit:67 ${PW} usershow \
+ -u $nonexistent_uid
+}
+
+atf_test_case user_show_uid
+user_show_uid_body() {
+ populate_etc_skel
+ atf_check -o not-empty ${PW} usershow -u 0
+}
+
+atf_init_test_cases() {
+ atf_add_test_case user_show_all
+ atf_add_test_case user_show_name
+ atf_add_test_case user_show_nonexistent_name
+ atf_add_test_case user_show_nonexistent_uid
+ atf_add_test_case user_show_uid
+}