diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-23 20:12:58 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-23 20:12:58 -0400 |
| commit | 10fa6f4e2e7150ad99827721ada1ae4badcc5e90 (patch) | |
| tree | 960065c8e69f1e7a4150ecf522e2f813c239b5ee /archive/gptel/tests/test-ai-config-gptel-backend-libs.el | |
| parent | f4cc70c69e7707dd4a686637e14885f5443fcca6 (diff) | |
| download | dotemacs-10fa6f4e2e7150ad99827721ada1ae4badcc5e90.tar.gz dotemacs-10fa6f4e2e7150ad99827721ada1ae4badcc5e90.zip | |
chore(ai): archive gptel and remove it from the live config
I archived gptel to archive/gptel/ since I rarely use it. Moved there: the six gptel modules (ai-config, ai-conversations, ai-conversations-browser, ai-mcp, ai-quick-ask, ai-rewrite), the gptel-tools/ directory, custom/gptel-prompts.el, their test files and utilities, and the four gptel-only specs.
Scrubbed from the live config: the ai-config require in init.el, which also drops the whole C-; a keymap; the gptel-mode emojify hook in font-config.el; the gptel-tools entries in the Makefile clean target and the coverage runner; and the gptel feature notes in README. Cancelled the open gptel tasks in todo.org (the AI Open Work issues, the feature-extension brainstorm, the velox gptel-magit bug).
ai-term stays. It is the ghostel Claude launcher, independent of gptel.
Verified: every module loads, a batch init launch reaches completion clean, and the full test suite shows only pre-existing coverage failures unrelated to this change.
Diffstat (limited to 'archive/gptel/tests/test-ai-config-gptel-backend-libs.el')
| -rw-r--r-- | archive/gptel/tests/test-ai-config-gptel-backend-libs.el | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/archive/gptel/tests/test-ai-config-gptel-backend-libs.el b/archive/gptel/tests/test-ai-config-gptel-backend-libs.el new file mode 100644 index 00000000..cbf48f44 --- /dev/null +++ b/archive/gptel/tests/test-ai-config-gptel-backend-libs.el @@ -0,0 +1,58 @@ +;;; test-ai-config-gptel-backend-libs.el --- Tests for gptel backend-lib loading -*- lexical-binding: t; -*- + +;;; Commentary: +;; Regression coverage for the "gptel-make-anthropic void" bug. The local +;; gptel fork (:load-path "~/code/gptel", :ensure nil) ships no generated +;; autoloads, so (require 'gptel) alone never loads gptel-anthropic / +;; gptel-openai where the gptel-make-* constructors live. The fix is to +;; require those backend libraries explicitly before constructing backends. +;; +;; These tests don't load gptel itself (it isn't reliably loadable in batch); +;; they stub `require' and the constructors to verify the loader requires both +;; libs and that `cj/ensure-gptel-backends' calls it before building backends. + +;;; Code: + +(require 'ert) +(require 'cl-lib) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(require 'ai-config) + +;; gptel defvars these at runtime; declare them here so the wiring test can +;; let-bind them in a batch session where gptel itself is not loaded. +(defvar gptel-backend) +(defvar gptel-model) + +(ert-deftest test-ai-config-gptel-load-backend-libs-requires-both () + "Normal: the loader requires gptel-anthropic and gptel-openai so the fork's +make-* constructors exist despite the missing autoloads." + (let ((required '())) + (cl-letf (((symbol-function 'require) + (lambda (feature &rest _) (push feature required) feature))) + (cj/--gptel-load-backend-libs)) + (should (memq 'gptel-anthropic required)) + (should (memq 'gptel-openai required)))) + +(ert-deftest test-ai-config-ensure-gptel-backends-loads-libs-first () + "Regression: `cj/ensure-gptel-backends' loads the backend libs before it +calls the constructors, so a fork without autoloads no longer signals +`void-function gptel-make-anthropic'." + (let ((loaded nil) + (gptel-claude-backend nil) + (gptel-chatgpt-backend nil) + (gptel-backend nil) + (gptel-model nil)) + (cl-letf (((symbol-function 'cj/--gptel-load-backend-libs) + (lambda () (setq loaded t))) + ((symbol-function 'gptel-make-anthropic) (lambda (&rest _) 'claude)) + ((symbol-function 'gptel-make-openai) (lambda (&rest _) 'chatgpt)) + ((symbol-function 'cj/anthropic-api-key) (lambda () "k")) + ((symbol-function 'cj/openai-api-key) (lambda () "k"))) + (cj/ensure-gptel-backends)) + (should loaded) + (should (eq gptel-claude-backend 'claude)) + (should (eq gptel-chatgpt-backend 'chatgpt)))) + +(provide 'test-ai-config-gptel-backend-libs) +;;; test-ai-config-gptel-backend-libs.el ends here |
