1 ;;; test-org-attach.el --- tests for org-attach.el -*- lexical-binding: t; -*-
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
30 (ert-deftest test-org-attach
/dired-attach-to-next-best-subtree
/1 ()
31 "Attach file at point in dired to subtree."
33 (let ((a-filename (make-temp-file "a"))) ; file is an attach candidate.
35 (org-test-with-temp-text-in-file
38 (dired temporary-file-directory
)
39 (assert (eq 'dired-mode major-mode
))
41 (dired-goto-file a-filename
)
43 (call-interactively #'org-attach-dired-to-subtree
)
46 (assert (eq 'org-mode major-mode
))
48 (search-forward "* foo")
49 ; expectation. tag ATTACH has been appended.
50 (reduce (lambda (x y
) (or x y
))
51 (mapcar (lambda (x) (string-equal "ATTACH" x
))
54 (org-element-at-point) 'headline
) :tags
))))
55 (delete-file a-filename
)))))
57 (ert-deftest test-org-attach
/dired-attach-to-next-best-subtree
/2 ()
58 "Attach 2 marked files."
60 (let ((a-filename (make-temp-file "a"))
61 (b-filename (make-temp-file "b"))) ; attach candidates.
63 (org-test-with-temp-text-in-file
66 (dired temporary-file-directory
)
67 (assert (eq 'dired-mode major-mode
))
69 (dired-goto-file a-filename
)
71 (dired-goto-file b-filename
)
74 (call-interactively #'org-attach-dired-to-subtree
)
77 (assert (eq 'org-mode major-mode
))
79 (search-forward "* foo")
80 (and (file-exists-p (concat (org-attach-dir) "/"
81 (file-name-nondirectory a-filename
)))
82 (file-exists-p (concat (org-attach-dir) "/"
83 (file-name-nondirectory b-filename
)))))
84 (delete-file a-filename
)
85 (delete-file b-filename
)))))
88 (provide 'test-org-attach
)
89 ;;; test-org-attach.el ends here