test-org/file-contents: Refactor duplicate test

* testing/lisp/test-org.el (test-org/file-contents): Avoid safety
prompt when testing.  Fix duplicate test testing optional argument for
`org-file-contents' (the argument were not passed previously).
This commit is contained in:
Ihor Radchenko 2024-02-09 15:07:35 +01:00
parent e3f327d1e6
commit 8e2ed45bb1
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 8 additions and 5 deletions

View File

@ -3982,8 +3982,9 @@ SCHEDULED: <2017-05-06 Sat>
(org-file-contents "http://some-valid-url"))
(kill-buffer buffer))))))
;; Throw error when trying to access an invalid URL.
(should-error
(let ((buffer (generate-new-buffer "url-retrieve-output")))
(should-not
(let ((buffer (generate-new-buffer "url-retrieve-output"))
(org-resource-download-policy t))
(unwind-protect
;; Simulate unsuccessful retrieval of a URL.
(cl-letf (((symbol-function 'url-retrieve-synchronously)
@ -3991,11 +3992,12 @@ SCHEDULED: <2017-05-06 Sat>
(with-current-buffer buffer
(insert "HTTP/1.1 404 Not found\n\ndoes not matter"))
buffer)))
(org-file-contents "http://this-url-must-not-exist"))
(org-file-contents "http://this-url-must-not-exist" 'noerror))
(kill-buffer buffer))))
;; Try to access an invalid URL, but do not throw an error.
(should-error
(let ((buffer (generate-new-buffer "url-retrieve-output")))
(let ((buffer (generate-new-buffer "url-retrieve-output"))
(org-resource-download-policy t))
(unwind-protect
;; Simulate unsuccessful retrieval of a URL.
(cl-letf (((symbol-function 'url-retrieve-synchronously)
@ -4006,7 +4008,8 @@ SCHEDULED: <2017-05-06 Sat>
(org-file-contents "http://this-url-must-not-exist"))
(kill-buffer buffer))))
(should
(let ((buffer (generate-new-buffer "url-retrieve-output")))
(let ((buffer (generate-new-buffer "url-retrieve-output"))
(org-resource-download-policy t))
(unwind-protect
;; Simulate unsuccessful retrieval of a URL.
(cl-letf (((symbol-function 'url-retrieve-synchronously)