fix org-roam--org-roam-file-p

fixes tests
This commit is contained in:
Jethro Kuan
2021-03-24 17:16:08 +08:00
parent 315e2dc447
commit 6bcf164036
3 changed files with 8 additions and 23 deletions

View File

@ -416,7 +416,7 @@ first encapsulating ID."
;;;;; Updating
(defun org-roam-db-sync (&optional force)
"Build the cache for `org-roam-directory'.
"Synchronize the cache state with the current Org files on-disk.
If FORCE, force a rebuild of the cache from scratch."
(interactive "P")
(when force (delete-file org-roam-db-location))

View File

@ -194,7 +194,7 @@ Like `file-name-extension', but does not strip version number."
"Return t if FILE is part of Org-roam system, nil otherwise.
If FILE is not specified, use the current buffer's file-path."
(when-let ((path (or file
(buffer-base-buffer (buffer-file-name)))))
(buffer-file-name (buffer-base-buffer)))))
(save-match-data
(and
(org-roam--org-file-p path)

View File

@ -23,31 +23,16 @@
(require 'buttercup)
(require 'org-roam)
(require 'dash)
(defvar test-org-roam-directory (expand-file-name "tests/roam-files")
"Directory containing org-roam test org files.")
(defun test-org-roam--init ()
"."
(let ((original-dir test-org-roam-directory)
(new-dir (expand-file-name (make-temp-name "org-roam") temporary-file-directory)))
(copy-directory original-dir new-dir)
(setq org-roam-directory new-dir)
(org-roam-setup)))
(defun test-org-roam--teardown ()
"."
(org-roam-teardown)
(delete-file org-roam-db-location)
(org-roam-db--close))
(describe "test files for org-roam-db-sync"
(describe "org-roam-db-sync"
(before-all
(test-org-roam--init))
(setq org-roam-directory (expand-file-name "tests/roam-files")
org-roam-db-location (expand-file-name "org-roam.db" temporary-file-directory))
(org-roam-setup))
(after-all
(test-org-roam--teardown))
(org-roam-teardown)
(delete-file org-roam-db-location))
(it "has the correct number of files"
(expect (caar (org-roam-db-query [:select (funcall count) :from files]))