Closed jgru closed 1 year ago
Dummy data for testing purposes can now be automatically created using the minimal-setup.el
provided in the wiki.
The relevant elisp functions are the following ones:
(setq test-org-roam-directory (make-temp-file "roam-" t))
(with-eval-after-load 'org-roam
(defun create-org-roam-dummy-note (title body)
"Create an org-roam note file with TITLE and content BODY."
(let* ((slug (org-roam-node-slug (org-roam-node-create :title title)))
(filename (concat (file-name-as-directory org-roam-directory)
(format "%d-%s.org"
(time-convert (current-time) 'integer)
slug)))
(org-id-overriding-file-name filename)
id)
(with-temp-buffer
filename
(insert ":PROPERTIES:\n:ID: \n:END:\n#+title: "
title)
(goto-char 25)
(setq id (org-id-get-create))
(goto-char (point-max))
(newline 2)
(insert body)
(write-file filename)
(org-roam-db-update-file filename))))
(defun populate-org-roam-with-dummy-notes ()
"Create some test notes in org-roam-directory."
(let ((elems '("alpha" "bravo" "charlie" "delta" "echo" "foxtrot")))
;; Check existence of org-roam-directory
(when (not (file-directory-p org-roam-directory))
(make-directory org-roam-directory))
;; Create the single notes
(dolist (elt elems )
(create-org-roam-dummy-note elt
(concat "This is the body of a note about " elt)))))
(populate-org-roam-with-dummy-notes))
This snippet creates notes in a uniquely named temp-directory by iterating over elems
.
The resulting files have the following simplistic structure:
:PROPERTIES:
:ID: a8b97174-48e6-453d-8f73-8e3cd1d955b0
:END:
#+title: alpha
This is the body of a note about alpha
This can be conveniently used to test consult-org-roam
's functionality
As proposed by @apc in the course of the discussion regarding #13, there should be a pre-populated
org-roam-directory
so that the package could be easily tested. To achieve this, a function should be created and documented in the wiki to make the configuration for testing purposes more complete and comprehensive.-- @apc