summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-07-18 18:58:12 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-07-18 18:58:12 +0200
commitd6e6016ba62edb2487eeaa2b087458f4366bc091 (patch)
tree070209631efe6b27949566cb48816d7f99a86942
parentcf5cb157435dc4495918017791e9063ffb260ba9 (diff)
downloadorg-mode-d6e6016ba62edb2487eeaa2b087458f4366bc091.tar.gz
test-org-clock: Fix failing test (again)
* testing/lisp/test-org-clock.el (test-org-clock/clocktable): Update test. (test-org-clock/clocktable1, test-org-clock/clocktable2, test-org-clock/clocktable-until-now): Merge tests into the previous one.
-rw-r--r--testing/lisp/test-org-clock.el96
1 files changed, 34 insertions, 62 deletions
diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el
index 3a5377d..335b7a6 100644
--- a/testing/lisp/test-org-clock.el
+++ b/testing/lisp/test-org-clock.el
@@ -84,86 +84,58 @@ contents. The clocktable doesn't appear in the buffer."
;;; Clocktable
-(defun test-org-clock/clocktable (string)
- (let* ((org-clock-total-time-cell-format "*%s*")
- (time (decode-time (current-time)))
- (oclock (format "%d:00" (nth 2 time)))
- (hour-before
- (let ((old (decode-time
- (apply #'encode-time
- (append (list 0 0 (1- (nth 2 time)))
- (nthcdr 3 time))))))
- (concat (and (= (nth 2 time) 0) "-1d ")
- (format "%d:00" (nth 2 old))))))
- ;; Install Clock lines in "Foo".
- (search-forward "** Foo")
- (forward-line)
- (insert (org-test-clock-create-clock "-2d 8:00" "-2d 13:00"))
- (insert (org-test-clock-create-clock hour-before oclock))
- ;; Install Clock lines in "Bar".
- (search-forward "** Bar")
- (forward-line)
- (insert (org-test-clock-create-clock "-10y 8:00" "-10y 12:00"))
- (insert (org-test-clock-create-clock "-2d 15:00" "-2d 18:00"))
- (insert (org-test-clock-create-clock "-1d 8:00" "-1d 13:00"))
- (insert (org-test-clock-create-clock "-1d 15:00" "-1d 18:00"))
- (insert (org-test-clock-create-clock hour-before))
- (goto-char (point-min))
- (forward-line)
- (test-org-clock-clocktable-contents-at-point string)))
-
-(ert-deftest test-org-clock/clocktable1 ()
+(ert-deftest test-org-clock/clocktable ()
"Test clocktable specifications."
;; Relative time: Previous two days.
(should
(equal
- "| Headline | Time | |
-|------------------------------+---------+-------|
-| *Total time* | *17:00* | |
-|------------------------------+---------+-------|
-| Relative times in clocktable | 17:00 | |
-| Foo | | 6:00 |
-| Bar | | 11:00 |
+ "| Headline | Time | |
+|------------------------------+--------+------|
+| *Total time* | *8:00* | |
+|------------------------------+--------+------|
+| Relative times in clocktable | 8:00 | |
+| Foo | | 8:00 |
"
(org-test-with-temp-text
- "* Relative times in clocktable\n** Foo\n** Bar\n"
- (test-org-clock/clocktable
- ":tstart \"<-2d>\" :tend \"<today>\" :indent nil")))))
-
-(ert-deftest test-org-clock/clocktable2 ()
- "Test clocktable specifications."
+ "* Relative times in clocktable\n** Foo\n<point>"
+ (insert (org-test-clock-create-clock "-3d 8:00" "-3d 12:00"))
+ (insert (org-test-clock-create-clock "-2d 15:00" "-2d 18:00"))
+ (insert (org-test-clock-create-clock "-1d 8:00" "-1d 13:00"))
+ (test-org-clock-clocktable-contents-at-point
+ ":tstart \"<-2d>\" :tend \"<today>\" :indent nil"))))
;; Relative time: Yesterday until now.
(should
(equal
"| Headline | Time | |
|------------------------------+--------+------|
-| *Total time* | *9:00* | |
+| *Total time* | *6:00* | |
|------------------------------+--------+------|
-| Relative times in clocktable | 9:00 | |
-| Foo | | 1:00 |
-| Bar | | 8:00 |
+| Relative times in clocktable | 6:00 | |
+| Foo | | 6:00 |
"
(org-test-with-temp-text
- "* Relative times in clocktable\n** Foo\n** Bar\n"
- (test-org-clock/clocktable
- ":tstart \"<yesterday>\" :tend \"<tomorrow>\" :indent nil")))))
-
-(ert-deftest test-org-clock/clocktable-until-now ()
- "Test clocktable specifications using `untilnow' range."
- ;; Relative time: Yesterday until now.
+ "* Relative times in clocktable\n** Foo\n<point>"
+ (insert (org-test-clock-create-clock "-2d 15:00" "-2d 18:00"))
+ (insert (org-test-clock-create-clock "-1d 8:00" "-1d 13:00"))
+ (insert (org-test-clock-create-clock ". 1:00" ". 2:00"))
+ (test-org-clock-clocktable-contents-at-point
+ ":tstart \"<yesterday>\" :tend \"<tomorrow>\" :indent nil"))))
+ ;; Test `untilnow' block.
(should
(equal
- "| Headline | Time | |
-|------------------------------+---------+-------|
-| *Total time* | *21:00* | |
-|------------------------------+---------+-------|
-| Relative times in clocktable | 21:00 | |
-| Foo | | 6:00 |
-| Bar | | 15:00 |
+ "| Headline | Time | |
+|------------------------------+--------+------|
+| *Total time* | *6:00* | |
+|------------------------------+--------+------|
+| Relative times in clocktable | 6:00 | |
+| Foo | | 6:00 |
"
(org-test-with-temp-text
- "* Relative times in clocktable\n** Foo\n** Bar\n"
- (test-org-clock/clocktable ":block untilnow :indent nil")))))
+ "* Relative times in clocktable\n** Foo\n<point>"
+ (insert (org-test-clock-create-clock "-10y 15:00" "-10y 18:00"))
+ (insert (org-test-clock-create-clock "-2d 15:00" "-2d 18:00"))
+ (test-org-clock-clocktable-contents-at-point
+ ":block untilnow :indent nil")))))
(provide 'test-org-clock)
;;; test-org-clock.el end here