summaryrefslogtreecommitdiff
path: root/bog-tests.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-02-02 23:56:15 -0500
committerKyle Meyer <kyle@kyleam.com>2014-02-03 00:50:18 -0500
commitf8725fe18333d96b23e7f1473de991114f8f181a (patch)
tree84d61f3b20c4551c2ae3d0736d9dfb72d5fdcb9d /bog-tests.el
parent96e5ef57785a05d9a7b618ac4985fbcea53344d7 (diff)
downloadbog-f8725fe18333d96b23e7f1473de991114f8f181a.tar.gz
Add function to rename and clean new BibTeX file
Diffstat (limited to 'bog-tests.el')
-rw-r--r--bog-tests.el43
1 files changed, 43 insertions, 0 deletions
diff --git a/bog-tests.el b/bog-tests.el
index e7ce2cc..24b5d0d 100644
--- a/bog-tests.el
+++ b/bog-tests.el
@@ -114,3 +114,46 @@
(org-mode)
(show-all)
(should-error (bog-citekey-action nil nil nil))))
+
+
+;;; BibTeX functions
+
+;; `bog-prepare-bib-file'
+
+(ert-deftest bog-prepare-bib-file ()
+ (let ((temp-file (make-temp-file "bog-testing-" nil ".bib"))
+ (citekey "name2010word"))
+ (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 (expand-file-name (concat citekey ".bib") "/tmp"))
+ (new-buffer (get-file-buffer new-file)))
+ (should-not new-buffer)
+ (delete-file new-file))))
+
+(ert-deftest bog-prepare-bib-file-was-open ()
+ (let ((temp-file (make-temp-file "bog-testing-" nil ".bib"))
+ (citekey "name2010word"))
+ (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))
+ (bog-prepare-bib-file temp-file)
+ (should-not (file-exists-p temp-file))
+ (let* ((new-file (expand-file-name (concat citekey ".bib") "/tmp"))
+ (new-buffer (get-file-buffer new-file)))
+ (should new-buffer)
+ (kill-buffer new-buffer)
+ (delete-file new-file))))