Hello, Kaushal Modi <kaushal.m...@gmail.com> writes:
> I have attached the same patch with one more test; rebased to master. Great. Thank you. > * lisp/org.el (org--file-cache): New internal variable to store > downloaded files' cache. > > * lisp/org.el (org-reset-file-cache): New function to clear the above > file cache. > > * lisp/org.el (org-mode-restart): Use org-reset-file-cache to clear > the file cache. > > * lisp/org.el (org-file-url-p): New function to test if the input > argument is a URL. It should be something like * lisp/org.el (org--file-cache): New variable (org-reset-file-cache): (org-file-url-p): New function. (org-mode-restart): Use new function. The purpose is to know in what commit the function was introduced, not what it does. > +Org opens the main file. If URL is specified, the contents are downloaded > +and stored in a temporary cache. @kbd{C-c C-c} on the settings line will > +also parse and load. @kbd{C-c C-c} on the @code{#+SETUPFILE:} line will also > +reset the temporary file cache. The last sentence is not correct. C-c C-c on any settings line resets the cache, not specifically on "#+SETUPFILE". > +(ert-deftest test-org/org-file-contents-url () > + "Test `org-file-contents' with a URL as input." > + (should > + (string= "#+BIND: variable value > +#+DESCRIPTION: l2 > +#+LANGUAGE: en > +#+SELECT_TAGS: b > +#+TITLE: b > +#+PROPERTY: a 1 > +" (org-file-contents > "http://orgmode.org/cgit.cgi/org-mode.git/plain/testing/examples/setupfile3.org"))) I'm worried about this test, and some other below. They require a proper internet access. Couldn't we fake `url-retrieve-synchronously' using `cl-letf' so as to produce a buffer with appropriate contents and return it? Something (untested) like (should (string= "foo" (let ((buffer (generate-new-buffer "test-ox"))) (unwind-protect (cl-letf (((symbol-function 'url-retrieve-synchronously) (lambda (&rest _) (with-current-buffer buffer (insert "HTTP 200 OK\n\nfoo")) buffer))) (org-file-contents "http://whatever")) (kill-buffer buffer))))) Regards, -- Nicolas Goaziou