Tests: Rename symbols, fix loading test data interactively
This commit is contained in:
parent
21c7dc1587
commit
d2f7b06f3d
1 changed files with 20 additions and 18 deletions
|
|
@ -45,7 +45,7 @@
|
||||||
('org-ql--pre-process-query t)
|
('org-ql--pre-process-query t)
|
||||||
(_ nil)))
|
(_ nil)))
|
||||||
(result (pcase sexp
|
(result (pcase sexp
|
||||||
(`(org-ql-expect ,args) (org-ql-test--format-result--ql `(org-ql test-buffer
|
(`(org-ql-expect ,args) (org-ql-test--format-result--ql `(org-ql org-ql-test-buffer
|
||||||
,@args
|
,@args
|
||||||
:action (org-ql-test-org-get-heading))))
|
:action (org-ql-test-org-get-heading))))
|
||||||
(`(org-ql . _) (org-ql-test--format-result--ql sexp))
|
(`(org-ql . _) (org-ql-test--format-result--ql sexp))
|
||||||
|
|
@ -80,7 +80,7 @@
|
||||||
(if-let* ((sexp (elisp--preceding-sexp))
|
(if-let* ((sexp (elisp--preceding-sexp))
|
||||||
(sexp (pcase sexp
|
(sexp (pcase sexp
|
||||||
(`(org-ql . ,_) (setf (car sexp) 'org-ql-agenda))
|
(`(org-ql . ,_) (setf (car sexp) 'org-ql-agenda))
|
||||||
(`(org-ql-expect ,ql-args . ,_) (setf sexp `(org-ql-select test-buffer
|
(`(org-ql-expect ,ql-args . ,_) (setf sexp `(org-ql-select org-ql-test-buffer
|
||||||
',@ql-args)))
|
',@ql-args)))
|
||||||
(_ nil))))
|
(_ nil))))
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ Based on Buttercup macro `it'."
|
||||||
RESULTS should be a list of strings as returned by
|
RESULTS should be a list of strings as returned by
|
||||||
`org-ql-test-org-get-heading'."
|
`org-ql-test-org-get-heading'."
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
`(expect (org-ql test-buffer
|
`(expect (org-ql org-ql-test-buffer
|
||||||
,@ql-args
|
,@ql-args
|
||||||
:action (org-ql-test-org-get-heading))
|
:action (org-ql-test-org-get-heading))
|
||||||
:to-equal ,results))
|
:to-equal ,results))
|
||||||
|
|
@ -138,10 +138,12 @@ RESULTS should be a list of strings as returned by
|
||||||
;; For Org 9.1.9.
|
;; For Org 9.1.9.
|
||||||
(substring-no-properties (org-get-heading t t t t))))
|
(substring-no-properties (org-get-heading t t t t))))
|
||||||
|
|
||||||
(setq test-buffer (find-file-noselect (concat default-directory "tests/data.org"))
|
(setq org-ql-test-buffer (->> (locate-dominating-file default-directory ".git")
|
||||||
|
(expand-file-name "tests/data.org")
|
||||||
|
find-file-noselect)
|
||||||
;; For manual testing:
|
;; For manual testing:
|
||||||
;; test-buffer (find-file-noselect "data.org")
|
;; org-ql-test-buffer (find-file-noselect "data.org")
|
||||||
num-headings (with-current-buffer test-buffer
|
org-ql-test-num-headings (with-current-buffer org-ql-test-buffer
|
||||||
(org-with-wide-buffer
|
(org-with-wide-buffer
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(cl-loop while (re-search-forward org-heading-regexp nil t)
|
(cl-loop while (re-search-forward org-heading-regexp nil t)
|
||||||
|
|
@ -180,21 +182,21 @@ RESULTS should be a list of strings as returned by
|
||||||
(describe "Query functions/macros"
|
(describe "Query functions/macros"
|
||||||
|
|
||||||
(it "org-ql"
|
(it "org-ql"
|
||||||
(expect (length (org-ql test-buffer
|
(expect (length (org-ql org-ql-test-buffer
|
||||||
(category)
|
(category)
|
||||||
:sort deadline))
|
:sort deadline))
|
||||||
:to-equal num-headings))
|
:to-equal org-ql-test-num-headings))
|
||||||
(it "org-ql-select"
|
(it "org-ql-select"
|
||||||
(expect (length (org-ql-select test-buffer
|
(expect (length (org-ql-select org-ql-test-buffer
|
||||||
'(category)
|
'(category)
|
||||||
:sort 'deadline))
|
:sort 'deadline))
|
||||||
:to-equal num-headings))
|
:to-equal org-ql-test-num-headings))
|
||||||
(it "org-ql-query"
|
(it "org-ql-query"
|
||||||
(expect (length (org-ql-query :select 'element
|
(expect (length (org-ql-query :select 'element
|
||||||
:from test-buffer
|
:from org-ql-test-buffer
|
||||||
:where '(category)
|
:where '(category)
|
||||||
:order-by 'date))
|
:order-by 'date))
|
||||||
:to-equal num-headings)))
|
:to-equal org-ql-test-num-headings)))
|
||||||
|
|
||||||
(it "Query pre-processing"
|
(it "Query pre-processing"
|
||||||
(expect (org-ql--pre-process-query '(and "string1" "string2"))
|
(expect (org-ql--pre-process-query '(and "string1" "string2"))
|
||||||
|
|
@ -330,9 +332,9 @@ RESULTS should be a list of strings as returned by
|
||||||
(describe "(category)"
|
(describe "(category)"
|
||||||
|
|
||||||
(org-ql-it "without arguments"
|
(org-ql-it "without arguments"
|
||||||
(expect (length (org-ql test-buffer
|
(expect (length (org-ql org-ql-test-buffer
|
||||||
(category)))
|
(category)))
|
||||||
:to-equal num-headings))
|
:to-equal org-ql-test-num-headings))
|
||||||
|
|
||||||
(org-ql-it "with a category"
|
(org-ql-it "with a category"
|
||||||
(org-ql-expect ((category "ambition"))
|
(org-ql-expect ((category "ambition"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue