diff options
author | Arun Isaac | 2017-02-23 01:00:34 +0530 |
---|---|---|
committer | Arun Isaac | 2017-02-23 01:00:34 +0530 |
commit | 7018c0841e34e6884682c06549b99d0b678a0d5d (patch) | |
tree | f856f8884130b752e6078f536b81e11aacc6ac22 /el-exiftool-tests.el | |
parent | ae597156bddec210732006f772289f677243c7fe (diff) | |
download | exiftool.el-7018c0841e34e6884682c06549b99d0b678a0d5d.tar.gz exiftool.el-7018c0841e34e6884682c06549b99d0b678a0d5d.tar.lz exiftool.el-7018c0841e34e6884682c06549b99d0b678a0d5d.zip |
Implement temporary test file copying in a macro.
* el-exiftool-tests.el (with-temp-test-file): New macro.
(read-write-test): Rewrite test using `with-temp-test-file'.
Diffstat (limited to 'el-exiftool-tests.el')
-rw-r--r-- | el-exiftool-tests.el | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/el-exiftool-tests.el b/el-exiftool-tests.el index 0025cf4..e16ad17 100644 --- a/el-exiftool-tests.el +++ b/el-exiftool-tests.el @@ -31,16 +31,20 @@ (require 'el-exiftool) (require 'ert) +(defmacro with-temp-test-file (test-filename temp-filename &rest body) + (declare (indent defun)) + `(let ((,temp-filename (make-temp-file "el-exiftool-" + nil (concat "-" ,test-filename)))) + (copy-file ,test-filename ,temp-filename t) + ,@body + (delete-file ,temp-filename))) + (ert-deftest read-write-test () - (let ((test-filename "test1.png")) - (let ((temp-filename (make-temp-file "el-exiftool-" - nil (concat "-" test-filename))) - (tag-value-alist '(("Marked" . "True")))) - (copy-file test-filename temp-filename t) + (with-temp-test-file "test1.png" temp-filename + (let ((tag-value-alist '(("Marked" . "True")))) (apply 'el-exiftool-write temp-filename tag-value-alist) (should (equal (el-exiftool-read temp-filename (caar tag-value-alist)) - tag-value-alist)) - (delete-file temp-filename)))) + tag-value-alist))))) (provide 'el-exiftool-tests) |