[Timeline] Add more tests for ‘timeline-tools-add-clockline-to-marker’

This time with running clock resolution.
This commit is contained in:
Daniel - 2019-02-17 10:02:40 +01:00
parent 3b6a78c19a
commit 5c9229d761
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
1 changed files with 140 additions and 0 deletions

View File

@ -191,4 +191,144 @@ CLOCK: [2018-01-07 Sun 13:00]--[2018-01-11 Thu 13:33] => 96:33
:END:
")))))
(ert-deftest timeline-tools-test-add-clockline-to-marker-2 ()
"Test `timeline-tools-add-clockline-to-marker with running
clock at same task."
(with-temp-buffer
(insert "
* Task 1
:LOGBOOK:
CLOCK: [2018-01-10 Wed 10:07]--[2018-01-12 Fri 14:00] => 51:53
CLOCK: [2018-01-08 Mon 16:15]--[2018-01-10 Wed 13:10] => 44:55
CLOCK: [2018-01-07 Sun 13:15]--[2018-01-07 Sun 14:00] => 0:45
:END:
* Task 2
:LOGBOOK:
CLOCK: [2018-01-10 Wed 13:10]
CLOCK: [2018-01-08 Mon 16:00]--[2018-01-08 Mon 16:15] => 0:15
CLOCK: [2018-01-07 Sun 15:13]--[2018-01-07 Sun 16:17] => 1:04
:END:
")
(org-mode)
(let (;; simulate running clock at Task 2
(org-clock-hd-marker (progn (goto-char 216) (point-marker)))
(org-clock-marker (progn (goto-char 264) (point-marker)))
(org-clock-start-time (org-time-string-to-time "[2018-01-10 Wed 13:10]")))
(let ((result (timeline-tools-add-clockline-to-marker
org-clock-hd-marker
(org-time-string-to-seconds "[2018-01-07 Sun 13:00]")
(org-time-string-to-seconds "[2018-01-11 Thu 13:33]"))))
(should (null result))
(should (equal org-clock-start-time
(append (org-time-string-to-time "[2018-01-11 Thu 13:33]")
'(0 0))))
(should (equal (buffer-string)
"
* Task 1
:LOGBOOK:
CLOCK: [2018-01-11 Thu 13:33]--[2018-01-12 Fri 14:00] => 24:27
:END:
* Task 2
:LOGBOOK:
CLOCK: [2018-01-11 Thu 13:33]
CLOCK: [2018-01-07 Sun 13:00]--[2018-01-11 Thu 13:33] => 96:33
:END:
"))))))
(ert-deftest timeline-tools-test-add-clockline-to-marker-3 ()
"Test `timeline-tools-add-clockline-to-marker with running
clock at same task."
(with-temp-buffer
(insert "
* Task 1
:LOGBOOK:
CLOCK: [2018-01-08 Mon 16:15]--[2018-01-10 Wed 13:10] => 44:55
CLOCK: [2018-01-07 Sun 13:15]--[2018-01-07 Sun 14:00] => 0:45
:END:
* Task 2
:LOGBOOK:
CLOCK: [2018-01-10 Wed 13:10]
CLOCK: [2018-01-08 Mon 16:00]--[2018-01-08 Mon 16:15] => 0:15
CLOCK: [2018-01-07 Sun 15:13]--[2018-01-07 Sun 16:17] => 1:04
:END:
")
(org-mode)
(let (;; simulate running clock at Task 2
(org-clock-hd-marker (progn (goto-char 153) (point-marker)))
(org-clock-marker (progn (goto-char 201) (point-marker)))
(org-clock-start-time (org-time-string-to-time "[2018-01-10 Wed 13:10]")))
(let ((result (timeline-tools-add-clockline-to-marker
(progn (goto-char 2) (point-marker))
(org-time-string-to-seconds "[2018-01-07 Sun 13:00]")
(org-time-string-to-seconds "[2018-01-11 Thu 13:33]"))))
(should (null result))
(should (equal org-clock-start-time
(append (org-time-string-to-time "[2018-01-11 Thu 13:33]")
'(0 0))))
(should (equal (buffer-string)
"
* Task 1
:LOGBOOK:
CLOCK: [2018-01-07 Sun 13:00]--[2018-01-11 Thu 13:33] => 96:33
:END:
* Task 2
:LOGBOOK:
CLOCK: [2018-01-11 Thu 13:33]
:END:
"))))))
(ert-deftest timeline-tools-test-add-clockline-to-marker-4 ()
"Test `timeline-tools-add-clockline-to-marker with running
clock at other task, and where afterwards only the running clock
line is left."
(with-temp-buffer
(insert "
* Task 1
:LOGBOOK:
CLOCK: [2018-01-10 Wed 10:07]--[2018-01-12 Fri 14:00] => 51:53
CLOCK: [2018-01-08 Mon 16:15]--[2018-01-10 Wed 13:10] => 44:55
CLOCK: [2018-01-07 Sun 13:15]--[2018-01-07 Sun 14:00] => 0:45
:END:
* Task 2
:LOGBOOK:
CLOCK: [2018-01-10 Wed 13:10]
CLOCK: [2018-01-08 Mon 16:00]--[2018-01-08 Mon 16:15] => 0:15
CLOCK: [2018-01-07 Sun 15:13]--[2018-01-07 Sun 16:17] => 1:04
:END:
")
(org-mode)
(let (;; simulate running clock at Task 2
(org-clock-hd-marker (progn (goto-char 216) (point-marker)))
(org-clock-marker (progn (goto-char 264) (point-marker)))
(org-clock-start-time (org-time-string-to-time "[2018-01-10 Wed 13:10]")))
(let ((result (timeline-tools-add-clockline-to-marker
(progn (goto-char 2) (point-marker))
(org-time-string-to-seconds "[2018-01-07 Sun 13:00]")
(org-time-string-to-seconds "[2018-01-11 Thu 13:33]"))))
(should (null result))
(should (equal org-clock-start-time
(append (org-time-string-to-time "[2018-01-11 Thu 13:33]")
'(0 0))))
(should (equal (buffer-string)
"
* Task 1
:LOGBOOK:
CLOCK: [2018-01-07 Sun 13:00]--[2018-01-11 Thu 13:33] => 96:33
CLOCK: [2018-01-11 Thu 13:33]--[2018-01-12 Fri 14:00] => 24:27
:END:
* Task 2
:LOGBOOK:
CLOCK: [2018-01-11 Thu 13:33]
:END:
"))))))
;; XXX: timeline-tools-add-clockline-to-marker (including updating current clock)