diff options
Diffstat (limited to 'bog-tests.el')
-rw-r--r-- | bog-tests.el | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/bog-tests.el b/bog-tests.el index be045f8..506cd27 100644 --- a/bog-tests.el +++ b/bog-tests.el @@ -2,6 +2,15 @@ (require 'org) (require 'bog) +;; Modified from magit-tests.el. +(defmacro bog-tests--with-temp-dir (&rest body) + (declare (indent 0) (debug t)) + (let ((dir (gensym))) + `(let ((,dir (file-name-as-directory (make-temp-file "dir" t)))) + (unwind-protect + (let ((default-directory ,dir)) ,@body) + (delete-directory ,dir t))))) + ;;; Citekey functions @@ -138,6 +147,29 @@ (should-error (bog-citekey-from-notes)))) +;;; PDF functions + +(ert-deftest bog-rename-staged-pdf-to-citekey-one-pdf () + (bog-tests--with-temp-dir + (let ((bog-stage-directory (expand-file-name "stage")) + (bog-pdf-directory (expand-file-name "pdfs")) + (citekey "name2010word")) + (make-directory bog-stage-directory) + (make-directory bog-pdf-directory) + (write-region "" nil (expand-file-name "one.pdf" bog-stage-directory)) + (with-temp-buffer + (insert (format "\n* top level\n\n** %s\n\nsome text\n" + citekey)) + (org-mode) + (show-all) + (re-search-backward bog-citekey-format) + (bog-rename-staged-pdf-to-citekey)) + (should (file-exists-p (expand-file-name + (concat citekey ".pdf") bog-pdf-directory))) + (should-not (file-exists-p (expand-file-name + (concat "one.pdf") bog-pdf-directory)))))) + + ;;; BibTeX functions ;; `bog-prepare-bib-file' |