38 lines
1.3 KiB
Common Lisp
38 lines
1.3 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)
|
|
(:import-from :scopes/testing #:deftest #:==))
|
|
|
|
(in-package :scopes/test-config)
|
|
|
|
(defvar *config* nil)
|
|
|
|
(defclass test-config (config:base)
|
|
((config:override-keys :initform '(user password))
|
|
(user :initarg :user :accessor user)
|
|
(password :initarg :password :accessor password)))
|
|
|
|
(defun run ()
|
|
(let ((t:*test-suite* (t:test-suite "config")))
|
|
(load (t:test-path "config-dummy" "etc"))
|
|
(test-make-path)
|
|
(test-env-override)
|
|
(t:show-result)))
|
|
|
|
(t:deftest test-make-path ()
|
|
(format t "~&test-path (config): ~s" (t:test-path "config"))
|
|
(format t "~&test-path (data): ~s" (t:test-path "test.db" "data"))
|
|
(format t "~&runtime-path: ~s" (util:runtime-path "config" "app" "etc"))
|
|
(format t "~&runtime-path (.env): ~s" (util:runtime-path ".env" "app"))
|
|
(format t "~&home-path: ~s" (util:home-path ".env.txt" "development" "cco")))
|
|
|
|
(t:deftest test-env-override ()
|
|
(format t "~&override-keys: ~s~%" (config:override-keys *config*))
|
|
(== (user *config*) "default-user"))
|