diff --git a/test/test-config.lisp b/test/test-config.lisp index 38a3317..49979fe 100644 --- a/test/test-config.lisp +++ b/test/test-config.lisp @@ -16,7 +16,16 @@ (defclass test-config (config:base) ((config:env-keys :initform '(:user :password)) - (config:env-path :initform (t:test-path ".test.env")))) + (config:env-path :initform (t:test-path ".test.env")) + (user :accessor user :initarg :user) + (password :accessor password :initarg :password))) + +(defmethod initialize-instance :after ((cfg test-config) &key &allow-other-keys) + (let* ((data (config:env-data cfg)) + (u (if data (gethash :user data))) + (pw (if data (gethash :password data)))) + (if u (setf (user cfg) u)) + (if pw (setf (password cfg) pw)))) (defun run () (let ((*config* nil) @@ -35,4 +44,6 @@ (t:deftest test-env-override () (let ((data (config:env-data *config*))) (== (gethash :user data) "user-from-env-file") - (== (gethash :password data) "very_secret"))) + (== (gethash :password data) "very_secret") + (== (user *config*) "user-from-env-file") + (== (password *config*) "very_secret")))