environment: modify-environment: Add tests.
* tests/environment.scm: New test. * Makefile.am (TESTS): Add it.
This commit is contained in:
parent
9d173e23bc
commit
e9fde01d27
2 changed files with 42 additions and 1 deletions
|
|
@ -68,7 +68,9 @@ SCM_LOG_DRIVER = \
|
|||
$(builddir)/pre-inst-env $(GUILE) \
|
||||
$(srcdir)/build-aux/test-driver.scm
|
||||
|
||||
TESTS = tests/job-specifier.scm
|
||||
TESTS = \
|
||||
tests/environment.scm \
|
||||
tests/job-specifier.scm
|
||||
|
||||
# Unset 'GUILE_LOAD_COMPILED_PATH' altogether while compiling. Otherwise, if
|
||||
# $GUILE_LOAD_COMPILED_PATH contains $(mcronmoduledir), we may find .go files
|
||||
|
|
|
|||
39
tests/environment.scm
Normal file
39
tests/environment.scm
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
;;;; environment.scm -- tests for (mcron environment) module
|
||||
;;; Copyright © 2016 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 environment))
|
||||
|
||||
(test-begin "environment")
|
||||
|
||||
(test-assert "modifiy-environment: basic"
|
||||
(begin
|
||||
(modify-environment '(("FOO" . "bar")) (getpw))
|
||||
(equal? (getenv "FOO") "bar")))
|
||||
|
||||
(test-assert "modifiy-environment: user & logname"
|
||||
;; Check that USER and LOGNAME environment variables can't be changed.
|
||||
(let* ((user-entry (pk (getpw)))
|
||||
(user-name (passwd:name user-entry)))
|
||||
(modify-environment '(("USER" . "alice")) user-entry)
|
||||
(modify-environment '(("LOGNAME" . "bob")) user-entry)
|
||||
(equal? user-name
|
||||
(pk (getenv "USER"))
|
||||
(pk (getenv "LOGNAME")))))
|
||||
|
||||
(test-end)
|
||||
Loading…
Add table
Add a link
Reference in a new issue