Org-mode mailing list
 help / color / mirror / Atom feed
* [PATCH] Add test checking org-log-done specs
@ 2021-07-11  6:04 Ihor Radchenko
  0 siblings, 0 replies; only message in thread
From: Ihor Radchenko @ 2021-07-11  6:04 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 163 bytes --]

Hi,

I did not find any tests checking logging specifications of Org mode.
Attached is an example implementation of such test for org-log-done
specs.

Best,
Ihor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-test-checking-org-log-done-specs.patch --]
[-- Type: text/x-diff, Size: 4381 bytes --]

From 2a58a82520de57142c6a397d811290f19789635f Mon Sep 17 00:00:00 2001
Message-Id: <2a58a82520de57142c6a397d811290f19789635f.1625983309.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sun, 11 Jul 2021 13:38:07 +0800
Subject: [PATCH] Add test checking org-log-done specs

* testing/lisp/test-org.el (test-org/org-log-done): New test
---
 testing/lisp/test-org.el | 126 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)

diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index c2267c32d..6922cbb4f 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -7418,6 +7418,132 @@ (ert-deftest test-org/auto-repeat-maybe ()
           (org-add-log-note))
         (buffer-string))))))
 
+(ert-deftest test-org/org-log-done ()
+  "Test `org-log-done' specifications."
+  ;; nil value.
+  (should
+   (string=
+    "* DONE task"
+    (let ((org-log-done nil)
+          (org-todo-keywords '((sequence "TODO" "DONE"))))
+      (org-test-with-temp-text
+          "* TODO task"
+        (org-todo "DONE")
+        (when (memq 'org-add-log-note post-command-hook)
+          (org-add-log-note))
+        (buffer-string)))))
+  ;; `time' value.
+  (should
+   (string=
+    (format
+    "* DONE task
+CLOSED: %s"
+    (org-test-with-temp-text ""
+      (org-insert-time-stamp (current-time) t t)
+      (buffer-string)))
+    (let ((org-log-done 'time)
+          (org-log-done-with-time t)
+          (org-todo-keywords '((sequence "TODO" "DONE"))))
+      (org-test-with-temp-text
+          "* TODO task"
+        (org-todo "DONE")
+        (when (memq 'org-add-log-note post-command-hook)
+          (org-add-log-note))
+        (buffer-string)))))
+  (should
+   (string=
+    (format
+    "* DONE task
+CLOSED: %s"
+    (org-test-with-temp-text ""
+      (org-insert-time-stamp (current-time) nil t)
+      (buffer-string)))
+    (let ((org-log-done 'time)
+          (org-log-done-with-time nil)
+          (org-todo-keywords '((sequence "TODO" "DONE"))))
+      (org-test-with-temp-text
+          "* TODO task"
+        (org-todo "DONE")
+        (when (memq 'org-add-log-note post-command-hook)
+          (org-add-log-note))
+        (buffer-string)))))
+  ;; TODO: Test `note' value.
+  ;; Test startup overrides.
+  (should
+   (string=
+    "#+STARTUP: nologdone
+* DONE task"
+    (let ((org-log-done 'time)
+          (org-todo-keywords '((sequence "TODO" "DONE"))))
+      (org-test-with-temp-text
+          "#+STARTUP: nologdone
+<point>* TODO task"
+        (org-set-regexps-and-options)
+        (org-todo "DONE")
+        (when (memq 'org-add-log-note post-command-hook)
+          (org-add-log-note))
+        (buffer-string)))))
+  (should
+   (string=
+    (format
+    "#+STARTUP: logdone
+* DONE task
+CLOSED: %s"
+    (org-test-with-temp-text ""
+      (org-insert-time-stamp (current-time) t t)
+      (buffer-string)))
+    (let ((org-log-done nil)
+          (org-log-done-with-time t)
+          (org-todo-keywords '((sequence "TODO" "DONE"))))
+      (org-test-with-temp-text
+          "#+STARTUP: logdone
+<point>* TODO task"
+        (org-set-regexps-and-options)
+        (org-todo "DONE")
+        (when (memq 'org-add-log-note post-command-hook)
+          (org-add-log-note))
+        (buffer-string)))))
+  ;; Test local property overrides.
+  (should
+   (string=
+    "* DONE task
+:PROPERTIES:
+:LOGGING: nil
+:END:"
+    (let ((org-log-done 'time)
+          (org-todo-keywords '((sequence "TODO" "DONE"))))
+      (org-test-with-temp-text
+          "* TODO task
+:PROPERTIES:
+:LOGGING: nil
+:END:"
+        (org-todo "DONE")
+        (when (memq 'org-add-log-note post-command-hook)
+          (org-add-log-note))
+        (buffer-string)))))
+  (should
+   (string=
+    (format
+    "* DONE task
+CLOSED: %s
+:PROPERTIES:
+:LOGGING: logdone
+:END:"
+    (org-test-with-temp-text ""
+      (org-insert-time-stamp (current-time) t t)
+      (buffer-string)))
+    (let ((org-log-done nil)
+          (org-log-done-with-time t)
+          (org-todo-keywords '((sequence "TODO" "DONE"))))
+      (org-test-with-temp-text
+          "* TODO task
+:PROPERTIES:
+:LOGGING: logdone
+:END:"
+        (org-todo "DONE")
+        (when (memq 'org-add-log-note post-command-hook)
+          (org-add-log-note))
+        (buffer-string))))))
 
 \f
 ;;; Timestamps API
-- 
2.31.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-11  6:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-11  6:04 [PATCH] Add test checking org-log-done specs Ihor Radchenko

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git