46 lines
1.6 KiB
Common Lisp
46 lines
1.6 KiB
Common Lisp
;;;; cl-scopes/test/test-config
|
|
|
|
;;;; Tests for the scopes/config functionality.
|
|
|
|
(defpackage :scopes/test-config
|
|
(:use :common-lisp)
|
|
(:local-nicknames (:config :scopes/config)
|
|
(:util :scopes/util)
|
|
(:t :scopes/testing))
|
|
(:export #:run #:user #:password)
|
|
(:import-from :scopes/testing #:deftest #:==))
|
|
|
|
(in-package :scopes/test-config)
|
|
|
|
(defclass child-config (config:base)
|
|
((user :accessor user :initarg :user)
|
|
(password :accessor password :initarg :password)
|
|
(address :accessor address :initarg :address)
|
|
(port :accessor port :initarg :port)
|
|
(docroot :accessor docroot :initarg :docroot)))
|
|
|
|
(defun run ()
|
|
(let ((t:*test-suite* (t:test-suite "config")))
|
|
(setf (uiop:getenv "SCOPES_PASSWORD") "very_secret")
|
|
(load (t:test-path "config-dummy" "etc"))
|
|
(test-make-path)
|
|
(test-env-override)
|
|
(t:show-result)))
|
|
|
|
(deftest test-make-path ()
|
|
;(format t "~&runtime-path (.env): ~s" (util:runtime-path ".env" "app"))
|
|
;(format t "~&home-path: ~s" (util:home-path ".env.txt" "lisp" "cl-scopes"))
|
|
(== (pathname-name (util:home-path ".env.txt" "lisp" "cl-scopes")) ".env"))
|
|
|
|
(deftest test-env-override ()
|
|
(let ((data (config:env-data config:*root*))
|
|
(child (car (config:children config:*root*))))
|
|
(== (gethash :user data) "user-from-env-file")
|
|
(== (gethash :password data) "very_secret")
|
|
(== (gethash :address data) nil)
|
|
(== (gethash :docroot data) nil)
|
|
(== (user child) "user-from-env-file")
|
|
(== (password child) "very_secret")
|
|
(== (address child) "")
|
|
(== (port child) "8199")
|
|
(== (docroot child) "")))
|