tests: close remaining contract gaps (action-dispatch, org-headline-add/find-by-id, tangle-sync, create-note, messaging-link/unlink)
Some checks failed
Deploy (Gitea) / deploy (push) Failing after 5s

This commit is contained in:
2026-05-05 13:52:59 -04:00
parent 3d237e9c78
commit ad8242fee6
12 changed files with 150 additions and 22 deletions

View File

@@ -15,7 +15,7 @@ Structural manipulation tools for Org-mode files. This skill handles reading, wr
4. (org-todo-set ast target-id status): sets TODO status via
org-property-set.
5. (org-headline-add ast parent-id title): adds a new child headline.
6. (org-find-headline-by-id ast id): returns the subtree for a matching
6. (org-headline-find-by-id ast id): returns the subtree for a matching
headline ID.
* Implementation
@@ -390,4 +390,24 @@ Verification of the structural manipulation for Org-mode files and their AST rep
:contents nil)))
(org-todo-set ast "id:todo001" "DONE")
(is (string= (getf (getf ast :properties) :TODO) "DONE"))))
(test test-org-headline-add
"Contract 5: org-headline-add inserts a child headline."
(let* ((ast (list :type :HEADLINE
:properties (list :ID "root" :TITLE "Root")
:contents nil)))
(is (eq t (org-headline-add ast "root" "New Child")))
(is (= 1 (length (getf ast :contents))))
(is (string= "New Child" (getf (getf (first (getf ast :contents)) :properties) :TITLE)))))
(test test-org-headline-find-by-id
"Contract 6: org-headline-find-by-id finds a headline by ID."
(let ((ast (list :type :HEADLINE :properties (list :ID "root" :TITLE "Root")
:contents (list (list :type :HEADLINE :properties (list :ID "child1" :TITLE "Child"))
(list :type :HEADLINE :properties (list :ID "child2" :TITLE "Child 2")))))))
(let ((found (org-headline-find-by-id ast "child2")))
(is (not (null found)))
(is (string= "Child 2" (getf (getf found :properties) :TITLE))))
(let ((missing (org-headline-find-by-id ast "nonexistent")))
(is (null missing) "Missing ID should return nil"))))
#+end_src