[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [PATCH 1/2] Add tests for org-refile-get-targets
From: |
Nicolas Goaziou |
Subject: |
Re: [O] [PATCH 1/2] Add tests for org-refile-get-targets |
Date: |
Mon, 15 May 2017 18:38:09 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
Hello,
Sebastian Reuße <address@hidden> writes:
> * testing/lisp/test-org.el: Add test.
> ---
Thank you.
> testing/examples/refile/a.org | 6 ++++++
> +
> +;;; org-refile
Nitpick: Sections in test-org.el are sorted alphabetically. So the new
"Refile" section could go between "Radio Targets" and "Sparse trees".
> +(ert-deftest test-org/org-refile-get-targets ()
> + "Test `org-refile-get-targets'."
> + (save-window-excursion
> + (let ((examples-dir (file-truename "../examples/refile/")))
> + (cd examples-dir)
> + (find-file-read-only "a.org")
> + (find-file-read-only "b.org")
> + (rename-buffer "gratuitous-prefix/b.org")
> + (let ((org-refile-targets '((("a.org" "b.org") :level . 2)))
> + (testcases
> + `((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 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")))))
> + (cl-loop for (use-outline-path . expected-targets) in testcases
> + do (let ((org-refile-use-outline-path use-outline-path))
> + (should
> + (equal
> + (mapcar #'car
> + (org-refile-get-targets))
> + expected-targets))))))))
> +
Would it be possible to split this big test into smaller ones, with
a description about what is really tested? See other tests in
"test-org.el" for some examples. Big tests tend to not being very
informative when they fail. IMO, code duplication is not an issue in
test files when it makes tests more readable/useful.
It would be even better if you can avoid relying on real files ("a.org"
and "b.org" in your patch), but if it makes the test too convoluted, no
worries.
Regards,
--
Nicolas Goaziou