diff options
| author | eltrac <hi@eltr.ac> | 2026-05-04 16:55:15 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-05-04 16:55:15 +0800 |
| commit | c0d6fbd2f8bf9db8195ee35342fc3d3d5d8af29a (patch) | |
| tree | 22c955ac3801d15e0509b23d193ddc361480b710 | |
| parent | c192a8a75fff3a68d4e5ec2259a845654621777d (diff) | |
test(processor): edge cases
| -rw-r--r-- | test/weepinbell/processor_test.clj | 34 |
1 files changed, 33 insertions, 1 deletions
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)))) + |
