diff options
author | Mathieu Lirzin <mthl@gnu.org> | 2018-03-25 00:28:52 +0100 |
---|---|---|
committer | Mathieu Lirzin <mthl@gnu.org> | 2018-03-25 00:38:26 +0100 |
commit | 5af999fb20c5bae645a5f2005f0411a1130b7455 (patch) | |
tree | 6d3a6aa23bddbf61f2b6333b54a6eeb6337536fc /tests | |
parent | 2169f4a7b349f34fc175412668098db3859493e2 (diff) | |
download | mcron-5af999fb20c5bae645a5f2005f0411a1130b7455.tar.gz mcron-5af999fb20c5bae645a5f2005f0411a1130b7455.tar.bz2 mcron-5af999fb20c5bae645a5f2005f0411a1130b7455.zip |
tests: Add "tests/utils.scm"
* tests/utils.scm: New test.
* Makefile.am (TESTS): Add it.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/utils.scm | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/utils.scm b/tests/utils.scm new file mode 100644 index 0000000..5ec5d11 --- /dev/null +++ b/tests/utils.scm @@ -0,0 +1,51 @@ +;;;; utils.scm -- tests for (mcron utils) module +;;; Copyright © 2018 Mathieu Lirzin <mthl@gnu.org> +;;; +;;; This file is part of GNU Mcron. +;;; +;;; GNU Mcron is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; GNU Mcron is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Mcron. If not, see <http://www.gnu.org/licenses/>. + +(use-modules (srfi srfi-64) + (mcron utils)) + +(test-begin "utils") + +(define entry + ;; Random user entry. + (getpw)) + +;;; Call 'get-user' with a valid uid. +(let ((uid (getuid))) + (test-equal "get-user: uid" + uid + (passwd:uid (get-user uid)))) + +;;; Call 'get-user' with a valid user name. +(let ((name (passwd:name entry))) + (test-equal "get-user: name" + name + (passwd:name (get-user name)))) + +;;; Call 'get-user' with a passwd entry. +(test-equal "get-user: passwd entry" + entry + (get-user entry)) + +;;; Call 'get-user' with an invalid uid. +(test-error "get-user: invalid uid" #t (get-user -20000)) + +;;; Call 'get-user' with an invalid spec. +(test-error "get-user: invalid spec" #t (get-user 'wrong)) + +(test-end) |