From b081d62276378b3168c92c06153fd59db0589535 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 24 May 2026 13:44:34 -0500 Subject: feat: pearl — manage Linear issues from org-mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pearl fetches Linear issues into an org file and syncs edits back. It covers list / custom views / saved queries, per-issue and bulk rendering with comments inline, conflict-aware sync of descriptions, titles, and comments, field commands for priority / state / assignee / labels, and a transient dispatch menu. The render folds to a scannable outline and nests issues under a sortable parent. Based on and inspired by Gael Blanchemain's linear-emacs. --- tests/testutil-request.el | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/testutil-request.el (limited to 'tests/testutil-request.el') diff --git a/tests/testutil-request.el b/tests/testutil-request.el new file mode 100644 index 0000000..a517bb6 --- /dev/null +++ b/tests/testutil-request.el @@ -0,0 +1,49 @@ +;;; testutil-request.el --- request mocking helpers for pearl tests -*- lexical-binding: t; -*- + +;; Copyright (C) 2026 Craig Jennings + +;;; Commentary: + +;; Shared helpers for stubbing the `request' library at the HTTP boundary. +;; A stub invokes the package's own :success or :error callback synchronously +;; with canned, json-read-shaped data, so the response-parsing and callback +;; logic runs for real without any network. Not a test file itself (no +;; test- prefix), so the suite runner ignores it; test files `require' it. + +;;; Code: + +(require 'cl-lib) + +(defun testutil-linear-request-success (data) + "Return a `request' replacement that invokes its :success callback with DATA." + (lambda (_url &rest args) + (let ((cb (plist-get args :success))) + (when cb (funcall cb :data data))))) + +(defun testutil-linear-request-error (msg) + "Return a `request' replacement that invokes its :error callback with MSG. +The :response carries a real `request-response' struct, matching what the +live library passes, so the package's status-code logging doesn't choke." + (lambda (_url &rest args) + (let ((cb (plist-get args :error))) + (when cb + (funcall cb :error-thrown msg + :response (make-request-response :status-code 500) + :data nil))))) + +(defmacro testutil-linear-with-response (data &rest body) + "Run BODY with `request' stubbed to succeed with DATA and an API key set." + (declare (indent 1)) + `(let ((pearl-api-key "test-key")) + (cl-letf (((symbol-function 'request) (testutil-linear-request-success ,data))) + ,@body))) + +(defmacro testutil-linear-with-error (msg &rest body) + "Run BODY with `request' stubbed to fail with MSG and an API key set." + (declare (indent 1)) + `(let ((pearl-api-key "test-key")) + (cl-letf (((symbol-function 'request) (testutil-linear-request-error ,msg))) + ,@body))) + +(provide 'testutil-request) +;;; testutil-request.el ends here -- cgit v1.2.3