branch: externals/ellama commit 3e29d0a7dac8762658c666a3706afc544f16f3b6 Author: Sergey Kostyaev <sskosty...@gmail.com> Commit: Sergey Kostyaev <sskosty...@gmail.com>
Fix partial callback in test Fixed the partial callback logic in the test-ellama-code-improve function to correctly simulate streaming text by appending lines instead of sending substrings. --- tests/test-ellama.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test-ellama.el b/tests/test-ellama.el index 6ed47a72ed..394184c861 100644 --- a/tests/test-ellama.el +++ b/tests/test-ellama.el @@ -37,14 +37,16 @@ (ert-deftest test-ellama-code-improve () (let ((original "(hello)\n") - (improved "```lisp\n(hello)\n```")) + (improved "```lisp\n(hello)\n```") + prev-lines) (with-temp-buffer (insert original) (cl-letf (((symbol-function 'llm-chat-streaming) (lambda (_provider prompt partial-callback response-callback _error-callback _multi-output) (should (string-match original (llm-chat-prompt-to-text prompt))) - (cl-loop for i from 0 to (- (length improved) 1) - do (funcall partial-callback `(:text ,(substring improved 0 i)))) + (dolist (s (string-lines improved)) + (funcall partial-callback `(:text ,(concat prev-lines s))) + (setq prev-lines (concat prev-lines s))) (funcall response-callback `(:text ,improved))))) (ellama-code-improve) (should (equal original (buffer-string)))))))