From: "Sebastian Reuße" <seb@wirrsal.net>
To: emacs-orgmode@gnu.org
Cc: "Sebastian Reuße" <seb@wirrsal.net>
Subject: [PATCH] Add tests for org-refile-get-targets
Date: Wed, 17 May 2017 20:44:58 +0200 [thread overview]
Message-ID: <20170517184458.19436-1-seb@wirrsal.net> (raw)
In-Reply-To: <87efvqxeha.fsf@nicolasgoaziou.fr>
* testing/lisp/test-org.el: Add test.
---
testing/examples/refile/a.org | 6 ++++
testing/examples/refile/b.org | 6 ++++
testing/lisp/test-org.el | 71 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 83 insertions(+)
create mode 100644 testing/examples/refile/a.org
create mode 100644 testing/examples/refile/b.org
diff --git a/testing/examples/refile/a.org b/testing/examples/refile/a.org
new file mode 100644
index 000000000..7ed235a52
--- /dev/null
+++ b/testing/examples/refile/a.org
@@ -0,0 +1,6 @@
+* a/1/1
+** a/1/2
+*** a/1/3
+* a/2/1
+** a/2/2
+*** a/2/3
diff --git a/testing/examples/refile/b.org b/testing/examples/refile/b.org
new file mode 100644
index 000000000..15359b16e
--- /dev/null
+++ b/testing/examples/refile/b.org
@@ -0,0 +1,6 @@
+* b/1/1
+** b/1/2
+*** b/1/3
+* b/2/1
+** b/2/2
+*** b/2/3
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index b8bd88957..099817064 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -5266,6 +5266,77 @@ (ert-deftest test-org/update-radio-target-regexp ()
(org-element-type (org-element-context))))))
\f
+;;; Refile
+
+(defvar test-org/refile-use-outline-path-examples-dir
+ (file-truename "../examples/refile/")
+ "Absolute path to example files used in ‘org-refile’ tests.")
+
+(defvar test-org/refile-use-outline-path-targets
+ `((nil . ("a/1/2"
+ "a/2/2"
+ "b/1/2"
+ "b/2/2"))
+ (file . ("a.org"
+ "a.org/a\\/1\\/1/a\\/1\\/2"
+ "a.org/a\\/2\\/1/a\\/2\\/2"
+ "b.org"
+ "b.org/b\\/1\\/1/b\\/1\\/2"
+ "b.org/b\\/2\\/1/b\\/2\\/2"))
+ (full-file-path . ,(mapcar (lambda (s)
+ (concat test-org/refile-use-outline-path-examples-dir s))
+ '("a.org"
+ "a.org/a\\/1\\/1/a\\/1\\/2"
+ "a.org/a\\/2\\/1/a\\/2\\/2"
+ "b.org"
+ "b.org/b\\/1\\/1/b\\/1\\/2"
+ "b.org/b\\/2\\/1/b\\/2\\/2")))
+ (buffer-name . ("a.org"
+ "a.org/a\\/1\\/1/a\\/1\\/2"
+ "a.org/a\\/2\\/1/a\\/2\\/2"
+ "gratuitous-prefix/b.org"
+ "gratuitous-prefix/b.org/b\\/1\\/1/b\\/1\\/2"
+ "gratuitous-prefix/b.org/b\\/2\\/1/b\\/2\\/2")))
+ "Alist of ‘refile-use-outline-path’ settings and associated \
+expected refile targets.")
+
+(defmacro test-org/refile-get-targets (use-outline-path)
+ "Helper macro to test ‘org-refile-get-targets’ with \
+‘org-refile-use-outline-path’ set to USE-OUTLINE-PATH."
+ `(save-window-excursion
+ (let ((org-refile-targets '((("a.org" "b.org")
+ :level . 2)))
+ (org-refile-use-outline-path ,use-outline-path))
+ (cd test-org/refile-use-outline-path-examples-dir)
+ (find-file-read-only "a.org")
+ (find-file-read-only "b.org")
+ (rename-buffer "gratuitous-prefix/b.org")
+ (should (equal
+ (mapcar #'car (org-refile-get-targets))
+ (alist-get ,use-outline-path
+ test-org/refile-use-outline-path-targets))))))
+
+(ert-deftest test-org/refile-get-targets-no-outline-path ()
+ "Test ‘org-refile-get-targets’ with \
+‘org-refile-use-outline-path’ to ‘nil’."
+ (test-org/refile-get-targets nil))
+
+(ert-deftest test-org/refile-get-targets-full-file-path ()
+ "Test ‘org-refile-get-targets’ with \
+‘org-refile-use-outline-path’ set to ‘full-file-path’."
+ (test-org/refile-get-targets 'full-file-path))
+
+(ert-deftest test-org/refile-get-targets-buffer-name ()
+ "Test `org-refile-get-targets' with \
+`org-refile-use-outline-path' set to ‘buffer-name’."
+ (test-org/refile-get-targets 'buffer-name))
+
+(ert-deftest test-org/refile-get-targets-file ()
+ "Test `org-refile-get-targets' with \
+`org-refile-use-outline-path' set to ‘file’."
+ (test-org/refile-get-targets 'file))
+
+\f
;;; Sparse trees
(ert-deftest test-org/match-sparse-tree ()
--
2.13.0
prev parent reply other threads:[~2017-05-17 18:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-15 12:54 [PATCH 1/2] Add tests for org-refile-get-targets Sebastian Reuße
2017-05-15 12:54 ` [PATCH 2/2] org-refile: Fix inconsistency when listing refile targets Sebastian Reuße
2017-05-17 12:54 ` Nicolas Goaziou
2017-06-21 7:05 ` Allen Li
2017-06-21 7:55 ` Sebastian Reuße
2017-06-21 8:01 ` Allen Li
2017-06-28 22:03 ` Allen Li
2017-07-03 6:44 ` Nicolas Goaziou
2017-07-07 6:55 ` Allen Li
2017-05-15 16:38 ` [PATCH 1/2] Add tests for org-refile-get-targets Nicolas Goaziou
2017-05-17 18:43 ` Sebastian Reuße
2017-05-22 0:38 ` Nicolas Goaziou
2017-05-22 6:46 ` Sebastian Reuße
2017-05-22 6:55 ` Nicolas Goaziou
2017-05-17 18:44 ` Sebastian Reuße [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170517184458.19436-1-seb@wirrsal.net \
--to=seb@wirrsal.net \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).