org-table: Improve shrinking on right-aligned and centered columns
[org-mode/org-tableheadings.git] / testing / lisp / test-org-attach.el
blob6d67ec559a0de742cbc501de5fd8e78147b718fd
1 ;;; test-org-attach.el --- tests for org-attach.el -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2017
5 ;; Author: Marco Wahl
6 ;; Keywords: internal
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/>.
21 ;;; Commentary:
25 ;;; Code:
27 (require 'org-test)
28 (require 'org-attach)
30 (ert-deftest test-org-attach/dired-attach-to-next-best-subtree/1 ()
31 "Attach file at point in dired to subtree."
32 (should
33 (let ((a-filename (make-temp-file "a"))) ; file is an attach candidate.
34 (unwind-protect
35 (org-test-with-temp-text-in-file
36 "* foo :foo:"
37 (split-window)
38 (dired temporary-file-directory)
39 (assert (eq 'dired-mode major-mode))
40 (revert-buffer)
41 (dired-goto-file a-filename)
42 ; action
43 (call-interactively #'org-attach-dired-to-subtree)
44 ; check
45 (delete-window)
46 (assert (eq 'org-mode major-mode))
47 (beginning-of-buffer)
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))
52 (plist-get
53 (plist-get
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."
59 (should
60 (let ((a-filename (make-temp-file "a"))
61 (b-filename (make-temp-file "b"))) ; attach candidates.
62 (unwind-protect
63 (org-test-with-temp-text-in-file
64 "* foo"
65 (split-window)
66 (dired temporary-file-directory)
67 (assert (eq 'dired-mode major-mode))
68 (revert-buffer)
69 (dired-goto-file a-filename)
70 (dired-mark 1)
71 (dired-goto-file b-filename)
72 (dired-mark 1)
73 ; action
74 (call-interactively #'org-attach-dired-to-subtree)
75 ; check
76 (delete-window)
77 (assert (eq 'org-mode major-mode))
78 (beginning-of-buffer)
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