Tests: Use test buffer for link safety tests
This commit is contained in:
parent
56647d4b11
commit
b90e6e25d0
1 changed files with 76 additions and 68 deletions
|
|
@ -1172,9 +1172,17 @@ RESULTS should be a list of strings as returned by
|
||||||
(require 'org-ql-search)
|
(require 'org-ql-search)
|
||||||
(require 'org-ql-view)
|
(require 'org-ql-view)
|
||||||
|
|
||||||
|
;; The :auto-map test requires there to be results (because the org-super-agenda :auto-map group's
|
||||||
|
;; key-form, where the safety check is, only gets evaluated when there are results). Using
|
||||||
|
;; `with-temp-buffer' in the `open-link' function causes the temp buffer to be killed before the results
|
||||||
|
;; have a chance to be gathered. So we make a test buffer and run the test in that, with a test heading.
|
||||||
|
|
||||||
|
(let ((test-buffer (get-buffer-create "*test-org-ql*")))
|
||||||
(cl-flet ((open-link
|
(cl-flet ((open-link
|
||||||
(link) (with-temp-buffer
|
(link) (with-current-buffer test-buffer
|
||||||
|
(erase-buffer)
|
||||||
(org-mode)
|
(org-mode)
|
||||||
|
(insert "* TODO Test heading \n\n")
|
||||||
(insert link)
|
(insert link)
|
||||||
(backward-char 1)
|
(backward-char 1)
|
||||||
(call-interactively #'org-open-at-point))))
|
(call-interactively #'org-open-at-point))))
|
||||||
|
|
@ -1244,7 +1252,7 @@ RESULTS should be a list of strings as returned by
|
||||||
(expect (open-link quoted-lambda-in-list-link)
|
(expect (open-link quoted-lambda-in-list-link)
|
||||||
:to-throw 'error '("Potentially unsafe value found in link’s SORT parameter (((quote (lambda (_ _) (message AHA))))). Link not opened"))
|
:to-throw 'error '("Potentially unsafe value found in link’s SORT parameter (((quote (lambda (_ _) (message AHA))))). Link not opened"))
|
||||||
(expect (open-link unquoted-lambda-in-list-link)
|
(expect (open-link unquoted-lambda-in-list-link)
|
||||||
:to-throw 'error '("Potentially unsafe value found in link’s SORT parameter (((lambda nil (message AHA)))). Link not opened")))))))
|
:to-throw 'error '("Potentially unsafe value found in link’s SORT parameter (((lambda nil (message AHA)))). Link not opened"))))))))
|
||||||
|
|
||||||
;; Local Variables:
|
;; Local Variables:
|
||||||
;; truncate-lines: t
|
;; truncate-lines: t
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue