From c0d6fbd2f8bf9db8195ee35342fc3d3d5d8af29a Mon Sep 17 00:00:00 2001 From: eltrac Date: Mon, 4 May 2026 16:55:15 +0800 Subject: test(processor): edge cases --- test/weepinbell/processor_test.clj | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/weepinbell/processor_test.clj b/test/weepinbell/processor_test.clj index bae7da3..950ee70 100644 --- a/test/weepinbell/processor_test.clj +++ b/test/weepinbell/processor_test.clj @@ -4,7 +4,7 @@ [ring.adapter.jetty :refer [run-jetty]] [weepinbell.processor :as p])) -(deftest verification-test +(deftest verification-happy-paths-test (testing "Test if processor can correctly verifies a Webmention." (let [handler (routes (GET "/1" [] @@ -24,3 +24,35 @@ (is (= true (p/verify-mention "http://localhost:28888/2" "https://alice.blog/article/abc"))) (.stop server)))) + +(deftest verification-error-cases-test + (testing "Test if processor can correctly verifies a Webmention." + (let [handler (routes + ;; Cases that source respond with an error + (GET "/a" [] + {:status 404 :headers {} + :body "Not Found."}) + (GET "/b" [] + {:status 502 :headers {} + :body "Bad Gateway"}) + ;; Cases that source does not contain target URL + (GET "/c" [] + {:status 200 :headers {} + :body "I didn't mention anyone"}) + (GET "/d" [] + {:status 200 :headers {} + :body (str "I mentioned christ but not alice\n" + "https://chris.blog/archive/xxx")}) + (GET "/e" [] + {:status 200 :headers {} + :body (str "I mentioned alice's other post\n" + "https://alice.blog/article/efg")})) + server (run-jetty handler {:port 28888 :join? false})] + ;; Cases that source respond with an error + (->> ["a" "b" "c" "d" "e" "f"] + (map #(is (not + (p/verify-mention (str "http://localhost:28888/" %) + "https://alice.blog/article/abc")))) + doall) + (.stop server)))) + -- cgit v1.2.3