summaryrefslogtreecommitdiff
path: root/bog-tests.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-02-15 15:56:42 -0500
committerKyle Meyer <kyle@kyleam.com>2014-02-15 16:04:55 -0500
commit93d0f444da93375de0480fe8e5009f2423040d79 (patch)
treed639d33a4d9c70651df7a410bcf763f410b5f551 /bog-tests.el
parent289b1399a8791eed9dd58b5364a958db1ee2054e (diff)
downloadbog-93d0f444da93375de0480fe8e5009f2423040d79.tar.gz
BUG: Fix renaming staged PDF when one choice
When 4dfcc52 changed remoed the path from choices, this should have been kept as the full path.
Diffstat (limited to 'bog-tests.el')
-rw-r--r--bog-tests.el32
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'