(internal): add longer sleep time to tests (#574)

This commit is contained in:
Jethro Kuan
2020-05-07 15:41:58 +08:00
committed by GitHub
parent 689f559080
commit f8f7e6009c

View File

@ -46,19 +46,27 @@
(defun org-roam-test-init () (defun org-roam-test-init ()
"." "."
(org-roam-db--close)
(let ((original-dir org-roam-test-directory) (let ((original-dir org-roam-test-directory)
(new-dir (expand-file-name (make-temp-name "org-roam") temporary-file-directory))) (new-dir (expand-file-name (make-temp-name "org-roam") temporary-file-directory)))
(copy-directory original-dir new-dir) (copy-directory original-dir new-dir)
(setq org-roam-directory new-dir) (setq org-roam-directory new-dir)
(org-roam-mode +1))) (org-roam-mode +1)
(sleep-for 2)))
(defun org-roam-test-teardown ()
(org-roam-mode -1)
(delete-file (org-roam-db--get))
(org-roam-db--close))
;;; Tests ;;; Tests
(describe "org-roam-db-build-cache" (describe "org-roam-db-build-cache"
(it "initializes correctly" (before-each
(org-roam-test-init) (org-roam-test-init))
(org-roam-db-build-cache)
(after-each
(org-roam-test-teardown))
(it "initializes correctly"
;; Cache ;; Cache
(expect (caar (org-roam-db-query [:select (funcall count) :from files])) :to-be 8) (expect (caar (org-roam-db-query [:select (funcall count) :from files])) :to-be 8)
(expect (caar (org-roam-db-query [:select (funcall count) :from links])) :to-be 5) (expect (caar (org-roam-db-query [:select (funcall count) :from links])) :to-be 5)
@ -116,9 +124,10 @@
(describe "org-roam-insert" (describe "org-roam-insert"
(before-each (before-each
(org-roam-test-init) (org-roam-test-init))
(org-roam-db--clear)
(org-roam-db-build-cache)) (after-each
(org-roam-test-teardown))
(it "temp1 -> foo" (it "temp1 -> foo"
(let ((buf (org-roam-test-find-new-file "temp1.org"))) (let ((buf (org-roam-test-find-new-file "temp1.org")))
@ -154,9 +163,10 @@
(describe "rename file updates cache" (describe "rename file updates cache"
(before-each (before-each
(org-roam-test-init) (org-roam-test-init))
(org-roam-db--clear)
(org-roam-db-build-cache)) (after-each
(org-roam-test-teardown))
(it "foo -> new_foo" (it "foo -> new_foo"
(rename-file (org-roam-test-abs-path "foo.org") (rename-file (org-roam-test-abs-path "foo.org")
@ -276,10 +286,10 @@
(describe "delete file updates cache" (describe "delete file updates cache"
(before-each (before-each
(org-roam-test-init) (org-roam-test-init))
(org-roam-db--clear)
(org-roam-db-build-cache) (after-each
(sleep-for 1)) (org-roam-test-teardown))
(it "delete foo" (it "delete foo"
(delete-file (org-roam-test-abs-path "foo.org")) (delete-file (org-roam-test-abs-path "foo.org"))