summaryrefslogtreecommitdiff
path: root/bog-tests.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-02-17 01:55:30 -0500
committerKyle Meyer <kyle@kyleam.com>2015-02-17 01:55:30 -0500
commite32756fcfa26f1e0bc215fecdb1e5b1f6b8604b6 (patch)
tree3669c1554ab20b5f27deb03e66b8fdc0cb850c3d /bog-tests.el
parent4dccd56e1fe424ed1af580e29a39c40642618b6b (diff)
downloadbog-e32756fcfa26f1e0bc215fecdb1e5b1f6b8604b6.tar.gz
Add option to store citekey files in subdirectories
Diffstat (limited to 'bog-tests.el')
-rw-r--r--bog-tests.el50
1 files changed, 48 insertions, 2 deletions
diff --git a/bog-tests.el b/bog-tests.el
index 3fefc0b..0bab888 100644
--- a/bog-tests.el
+++ b/bog-tests.el
@@ -397,6 +397,26 @@ some text"
(should-not (file-exists-p (expand-file-name
(concat "one.pdf") bog-stage-directory))))))
+(ert-deftest bog-rename-staged-file-to-citekey-one-file-subdir ()
+ (bog-tests--with-temp-dir
+ (let ((bog-stage-directory (expand-file-name "stage"))
+ (bog-file-directory (expand-file-name "citekey-files"))
+ (citekey "name2010word")
+ (bog-subdirectory-group 2))
+ (make-directory bog-stage-directory)
+ (make-directory bog-file-directory)
+ (write-region "" nil (expand-file-name "one.pdf" bog-stage-directory))
+ (bog-tests--with-temp-text
+ "
+* top level
+** <point><citekey>
+some text"
+ (bog-rename-staged-file-to-citekey))
+ (should (file-exists-p (expand-file-name
+ (concat "2010/" citekey ".pdf") bog-file-directory)))
+ (should-not (file-exists-p (expand-file-name
+ (concat "one.pdf") bog-stage-directory))))))
+
(ert-deftest bog-file-citekeys-multiple-variants ()
(bog-tests--with-temp-dir
(let* ((bog-file-directory (expand-file-name "citekey-files"))
@@ -422,7 +442,8 @@ some text"
(let ((temp-file (make-temp-file
(expand-file-name "bog-testing-" default-directory)
nil ".bib"))
- (citekey "name2010word"))
+ (citekey "name2010word")
+ (bog-bib-directory default-directory))
(with-current-buffer (find-file-noselect temp-file)
(insert (format "\n@article{%s,\n" citekey)
"title = {A title},\n"
@@ -436,6 +457,7 @@ some text"
(should-not (file-exists-p temp-file))
(let* ((new-file (concat citekey ".bib"))
(new-buffer (get-file-buffer new-file)))
+ (should (file-exists-p new-file))
(should-not new-buffer)
(delete-file new-file)))))
@@ -444,7 +466,8 @@ some text"
(let ((temp-file (make-temp-file
(expand-file-name "bog-testing-" default-directory)
nil ".bib"))
- (citekey "name2010word"))
+ (citekey "name2010word")
+ (bog-bib-directory default-directory))
(with-current-buffer (find-file-noselect temp-file)
(insert (format "\n@article{%s,\n" citekey)
"title = {A title},\n"
@@ -461,6 +484,29 @@ some text"
(kill-buffer new-buffer)
(delete-file new-file)))))
+(ert-deftest bog--prepare-bib-file-subdir ()
+ (bog-tests--with-temp-dir
+ (let ((temp-file (make-temp-file
+ (expand-file-name "bog-testing-" default-directory)
+ nil ".bib"))
+ (citekey "name2010word")
+ (bog-bib-directory default-directory)
+ (bog-subdirectory-group 2))
+ (with-current-buffer (find-file-noselect temp-file)
+ (insert (format "\n@article{%s,\n" citekey)
+ "title = {A title},\n"
+ "author = {Last, First},\n"
+ "journal = {Some journal},\n"
+ "year = 2009,\n"
+ "\n}")
+ (save-buffer))
+ (kill-buffer (get-file-buffer temp-file))
+ (bog--prepare-bib-file temp-file)
+ (should-not (file-exists-p temp-file))
+ (let ((new-file (concat "2010/" citekey ".bib")))
+ (should (file-exists-p new-file))
+ (delete-file new-file)))))
+
;; `bog-sort-topic-headings-in-buffer'
(ert-deftest bog-sort-topic-headings-in-buffer ()