;;; test-pearl-issues.el --- Tests for pearl issue fetch/create -*- lexical-binding: t; -*- ;; Copyright (C) 2026 Craig Jennings ;; Author: Craig Jennings ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; Tests for issue creation with `request' stubbed, focused on ;; `pearl--created-issue' (the success-checking helper that prevents ;; phantom "created" reports) and the create-issue async path. ;;; Code: (require 'test-bootstrap (expand-file-name "test-bootstrap.el")) (require 'testutil-request (expand-file-name "testutil-request.el")) ;;; pearl--created-issue (pure) (ert-deftest test-pearl-created-issue-success-returns-node () "A successful create returns the issue node." (let ((issue (pearl--created-issue '((data (issueCreate (success . t) (issue (id . "i1") (identifier . "ENG-1") (title . "T")))))))) (should (string-equal "ENG-1" (cdr (assoc 'identifier issue)))))) (ert-deftest test-pearl-created-issue-soft-fail-returns-nil () "A soft failure (success=false, issue=null) returns nil, not a phantom node." (should (null (pearl--created-issue '((data (issueCreate (success . :json-false) (issue)))))))) (ert-deftest test-pearl-created-issue-graphql-error-returns-nil () "A GraphQL error body (no data) returns nil." (should (null (pearl--created-issue '((errors . (((message . "bad"))))))))) (ert-deftest test-pearl-created-issue-empty-response-returns-nil () "A nil/empty response returns nil." (should (null (pearl--created-issue nil)))) ;;; pearl-create-issue-async (ert-deftest test-pearl-create-issue-async-success-passes-issue () "A successful create passes the issue node to the callback." (let ((got 'unset)) (testutil-linear-with-response '((data (issueCreate (success . t) (issue (id . "i1") (identifier . "ENG-1") (title . "T"))))) (pearl-create-issue-async "T" "" "team" (lambda (i) (setq got i)))) (should (string-equal "ENG-1" (cdr (assoc 'identifier got)))))) (ert-deftest test-pearl-create-issue-async-soft-fail-passes-nil () "A soft failure passes nil to the callback rather than a phantom issue." (let ((got 'unset)) (testutil-linear-with-response '((data (issueCreate (success . :json-false) (issue)))) (pearl-create-issue-async "T" "" "team" (lambda (i) (setq got i)))) (should (null got)))) (provide 'test-pearl-issues) ;;; test-pearl-issues.el ends here