feat: add SSE URL construction and connection management

This commit is contained in:
2026-06-11 12:45:25 -04:00
parent a4dbcf8287
commit 15baff4f26
2 changed files with 48 additions and 0 deletions
+19
View File
@@ -9,6 +9,9 @@
(require 'ert)
(require 'noise-sse)
(defvar noise-signal-cli-address)
(defvar noise-account)
(ert-deftest noise-sse--parse-event-basic ()
"Parse a basic SSE event with data field."
(let ((event "data: {\"type\":\"message\",\"content\":\"hello\"}\n\n"))
@@ -76,5 +79,21 @@
(noise-sse--filter nil "}\n\n")
(should (= 1 (length processed-events)))))))
(ert-deftest noise-sse--build-url ()
"Build SSE endpoint URL from base address."
(let ((noise-signal-cli-address "http://localhost:8080")
(noise-account "+15551234567"))
(let ((url (noise-sse--build-url)))
(should (string-match-p "/api/v1/events" url))
(should (string-match-p "account=%2B15551234567" url)))))
(ert-deftest noise-sse--build-url-no-account ()
"Build SSE endpoint URL without account parameter."
(let ((noise-signal-cli-address "http://localhost:8080")
(noise-account nil))
(let ((url (noise-sse--build-url)))
(should (string-match-p "/api/v1/events" url))
(should-not (string-match-p "account=" url)))))
(provide 'noise-sse-test)
;;; noise-sse-test.el ends here