From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Sebastian=20Reu=C3=9Fe?= Subject: [PATCH] Add tests for org-refile-get-targets Date: Wed, 17 May 2017 20:44:58 +0200 Message-ID: <20170517184458.19436-1-seb@wirrsal.net> References: <87efvqxeha.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB3wc-00015P-2H for emacs-orgmode@gnu.org; Wed, 17 May 2017 14:45:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB3wY-0007BI-VH for emacs-orgmode@gnu.org; Wed, 17 May 2017 14:45:10 -0400 Received: from wirrsal.net ([188.68.36.149]:37666 helo=mail.wirrsal.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dB3wY-00079c-KX for emacs-orgmode@gnu.org; Wed, 17 May 2017 14:45:06 -0400 In-Reply-To: <87efvqxeha.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Cc: =?UTF-8?q?Sebastian=20Reu=C3=9Fe?= * 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.or= g 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.or= g 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)))))) =20 =0C +;;; Refile + +(defvar test-org/refile-use-outline-path-examples-dir + (file-truename "../examples/refile/") + "Absolute path to example files used in =E2=80=98org-refile=E2=80=99 t= ests.") + +(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 =E2=80=98refile-use-outline-path=E2=80=99 settings and assoc= iated \ +expected refile targets.") + +(defmacro test-org/refile-get-targets (use-outline-path) + "Helper macro to test =E2=80=98org-refile-get-targets=E2=80=99 with \ +=E2=80=98org-refile-use-outline-path=E2=80=99 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 =E2=80=98org-refile-get-targets=E2=80=99 with \ +=E2=80=98org-refile-use-outline-path=E2=80=99 to =E2=80=98nil=E2=80=99." + (test-org/refile-get-targets nil)) + +(ert-deftest test-org/refile-get-targets-full-file-path () + "Test =E2=80=98org-refile-get-targets=E2=80=99 with \ +=E2=80=98org-refile-use-outline-path=E2=80=99 set to =E2=80=98full-file-= path=E2=80=99." + (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 =E2=80=98buffer-name=E2=80=99." + (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 =E2=80=98file=E2=80=99." + (test-org/refile-get-targets 'file)) + +=0C ;;; Sparse trees =20 (ert-deftest test-org/match-sparse-tree () --=20 2.13.0