diff options
author | Mathieu Lirzin <mthl@gnu.org> | 2018-03-26 22:42:26 +0200 |
---|---|---|
committer | Mathieu Lirzin <mthl@gnu.org> | 2018-03-27 03:13:14 +0200 |
commit | 15fa52f7ec85b3c2cb9f00ec8609dfe63a9ea9cd (patch) | |
tree | bc17945ecb6e43e003abbe2ee50bf62d34b9e8e0 /tests | |
parent | 56f85cfd8aef4a0f2668c5fa72ae032ff1652c8b (diff) | |
download | mcron-15fa52f7ec85b3c2cb9f00ec8609dfe63a9ea9cd.tar.gz mcron-15fa52f7ec85b3c2cb9f00ec8609dfe63a9ea9cd.tar.bz2 mcron-15fa52f7ec85b3c2cb9f00ec8609dfe63a9ea9cd.zip |
job-specifier: Box 'configuration-user' global variable
* src/mcron/job-specifier.scm (configuration-user): Box it using
SRFI-111 to be explicit about the mutability of this object.
(job): Adapt.
(set-configuration-user): Adapt and use 'get-user'.
* tests/job-specifier.scm ("set-configuration-user: passwd entry")
("set-configuration-user: invalid uid", "set-configuration-user: uid")
("set-configuration-user: invalid spec")
("set-configuration-user: name"): New tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/job-specifier.scm | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/job-specifier.scm b/tests/job-specifier.scm index d0c6ae3..636c1a1 100644 --- a/tests/job-specifier.scm +++ b/tests/job-specifier.scm @@ -18,6 +18,7 @@ (use-modules (ice-9 match) (srfi srfi-64) + (srfi srfi-111) (mcron job-specifier)) (test-begin "job-specifier") @@ -86,4 +87,49 @@ (list (next-second '(52 55)) (next-second-from 14))) +;;; +;;; Check 'configuration-user' manipulation +;;; + +(define configuration-user (@@ (mcron job-specifier) configuration-user)) + +;;; Call 'set-configuration-user' with a valid uid. +(let ((uid (getuid))) + (test-equal "set-configuration-user: uid" + uid + (begin + (set-configuration-user uid) + (passwd:uid (unbox configuration-user))))) + +(define entry + ;; Random user entry. + (getpw)) + +;;; Call 'set-configuration-user' with a valid user name. +(let ((name (passwd:name entry))) + (test-equal "set-configuration-user: name" + name + (begin + (set-configuration-user name) + (passwd:name (unbox configuration-user))))) + +(define root-entry (getpw 0)) + +;;; Call 'set-configuration-user' with a passwd entry. +(test-equal "set-configuration-user: passwd entry" + root-entry + (begin + (set-configuration-user root-entry) + (unbox configuration-user))) + +;;; Call 'set-configuration-user' with an invalid uid. +(test-error "set-configuration-user: invalid uid" + #t + (set-configuration-user -20000)) + +;;; Call 'set-configuration-user' with an invalid spec. +(test-error "set-configuration-user: invalid spec" + #t + (set-configuration-user 'wrong)) + (test-end) |