summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoreltrac <hi@eltr.ac>2026-10-06 17:40:03 +0800
committereltrac <hi@eltr.ac>2026-10-06 17:41:15 +0800
commit4030d4d921fed3e9abea28268fe499fbaedb5dfc (patch)
treea35e393824af254e3926f605759749615a42a267 /test
parent99ac7a49687ed353ee3919bd1d635429033a577f (diff)
core, processor: refactor startup; graceful shutdown
- implement a functional rewrite of core.clj, no more `def`, no more states. callable from an REPL - handle SIGINT/SIGTERM and perform graceful shutdown - print clear logs when starting up and shutting down
Diffstat (limited to 'test')
-rw-r--r--test/weepinbell/processor_starter_test.clj48
1 files changed, 30 insertions, 18 deletions
diff --git a/test/weepinbell/processor_starter_test.clj b/test/weepinbell/processor_starter_test.clj
index 65f6427..df90995 100644
--- a/test/weepinbell/processor_starter_test.clj
+++ b/test/weepinbell/processor_starter_test.clj
@@ -3,23 +3,35 @@
[clojure.core.async :refer [chan put!]]
[weepinbell.processor.starter :refer [start-processor]]))
-(def test-wmc (chan))
-(def received (promise))
-(def processor-meta {:wmc test-wmc
- :callbacks {:on-receive (fn [_] (deliver received true))
- :on-create (fn [_])
- :on-delete (fn [_])
- :on-update (fn [_])}
- :storage {:get (fn [& _])
- :delete (fn [& _])
- :append (fn [& _])
- :update (fn [& _])
- :get-by-domain (fn [& _])}
- :config {:base-url "https://test.com"
- :allowed-target-domains ["test.com"]}})
+(defn- test-processor [test-wmc received?]
+ {:pre [(instance? clojure.lang.IPending received?)]}
+ (let [pmeta {:wmc test-wmc
+ :callbacks {:on-receive (fn [_] (deliver received? true))
+ :on-create (fn [_])
+ :on-delete (fn [_])
+ :on-update (fn [_])}
+ :storage {:get (fn [& _])
+ :delete (fn [& _])
+ :append (fn [& _])
+ :update (fn [& _])
+ :get-by-domain (fn [& _])}
+ :config {:base-url "https://test.com"
+ :allowed-target-domains ["test.com"]}}]
+ (start-processor pmeta)))
(deftest start-processor-test
- (testing "starting processor and putting a fake webmention in queue"
- (start-processor processor-meta)
- (put! test-wmc {:s "s" :t "t"})
- (is (deref received 50 false))))
+ (testing "graceful shutdown"
+ (let [test-wmc (chan)
+ received? (promise)
+ shutdown (test-processor test-wmc received?)]
+ (shutdown)
+ (put! test-wmc {:s "s" :t "t"})
+ (is (not (deref received? 50 false)))))
+ (testing "processor starting and taking webmention"
+ (let [test-wmc (chan)
+ received? (promise)
+ shutdown (test-processor test-wmc received?)]
+ (put! test-wmc {:s "s" :t "t"})
+ (is (deref received? 50 false))
+ (shutdown))))
+