diff --git a/test/test.el b/test/test.el index 7158fec..599e0b9 100644 --- a/test/test.el +++ b/test/test.el @@ -18,6 +18,8 @@ ;;;; Variables (defconst org-super-agenda-test-date "2017-07-05 12:00") +;; (org-read-date t t org-super-agenda-test-date)) +(defconst org-super-agenda-test-date-internal '(22876 47264)) (defvar org-super-agenda-test-results (ht-create)) (defvar org-super-agenda-test-save-results nil) (defvar org-super-agenda-test-show-results nil) @@ -58,6 +60,19 @@ (defun org-super-agenda-test--diary-sunset () (cl-second (org-super-agenda-test--diary-sunrise-sunset-split))) + +;;;; Relative dates + +(defun org-read-date-get-relative-hack (orig-fun &rest args) + ;; (defun org-read-date-get-relative (s today default) + (message "first called with args %s" args) + (ad-set-argument 'args 1 org-super-agenda-test-date-internal) + (ad-set-argument 'args 2 org-super-agenda-test-date-internal) + (message "then calling with args %s" args) + (let ((res (apply orig-fun args))) + (message "returned %s" res) + res)) + ;;;; Commands (cl-defun org-super-agenda-test--update-all () @@ -530,10 +545,25 @@ already loaded." (should (org-super-agenda-test--run :groups '((:deadline (after "2017-07-10")))))) +(ert-deftest org-super-agenda-test--:deadline-after-relative () + ;; NOTE: is safe for parallel testing? + (advice-add 'org-read-date-get-relative :around #'org-read-date-get-relative-hack) + (should (org-super-agenda-test--run + :groups '((:deadline (after "+5d"))))) + (advice-remove 'org-read-date-get-relative #'org-read-date-get-relative-hack)) + +(ert-deftest org-super-agenda-test--:deadline-before-relative () + ;; NOTE: is safe for parallel testing? + (advice-add 'org-read-date-get-relative :around #'org-read-date-get-relative-hack) + (should (org-super-agenda-test--run + :groups '((:deadline (before "+5d"))))) + (advice-remove 'org-read-date-get-relative #'org-read-date-get-relative-hack)) + (ert-deftest org-super-agenda-test--:effort< () ;; DONE: Works. (should (org-super-agenda-test--run :groups '((:effort< "5"))))) + (ert-deftest org-super-agenda-test--:effort> () ;; DONE: Works. (should (org-super-agenda-test--run