This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-30
Channels
- # adventofcode (3)
- # announcements (4)
- # babashka (42)
- # beginners (56)
- # biff (23)
- # cider (8)
- # clj-yaml (2)
- # cljdoc (16)
- # clojure (83)
- # clojure-europe (52)
- # clojure-nl (3)
- # clojure-norway (4)
- # clojure-sweden (2)
- # clojure-uk (2)
- # clojurebridge (1)
- # clojurescript (2)
- # cloverage (1)
- # cursive (11)
- # data-oriented-programming (1)
- # deps-new (2)
- # dev-tooling (2)
- # emacs (3)
- # etaoin (4)
- # events (5)
- # fulcro (5)
- # gratitude (3)
- # java (3)
- # jobs (1)
- # jobs-discuss (1)
- # joyride (33)
- # malli (16)
- # music (1)
- # nbb (1)
- # nrepl (4)
- # nyc (1)
- # off-topic (25)
- # pathom (8)
- # re-frame (1)
- # reitit (7)
- # remote-jobs (2)
- # shadow-cljs (6)
- # tools-deps (9)
I'm using reitit.ring.middleware.muuntaja/format-request-middleware
(along with negotiate and response) with the default options and it seems to have different behavior when calling it via an HTTP request in a running server vs just using the handler as a function on a ring-mock
request in my unit tests. When I send a request with invalid JSON the server implementation does as expected and fails it, getting caught by my exception middleware, and returns a 400. However, the unit test / REPL implementation with ring-mock
does not fail and passes on the invalid JSON as a string where it fails in coercion. Everything is identical between the two as far as I can tell... Any ideas on why this might be the case?
Yeah, I'm using this:
(-> (ring-mock/request :post path)
(ring-mock/body (if (string? body) body (json/write-value-as-string body)))
(ring-mock/header :content-type "application/json"))
Yep, looks good. That was my first guess. And I don’t have better guesses but something being different in the request. Also worth checking if there’s anything interesting done when the real server is started
Thanks for the help. Yeah, I've been diffing the two and can't seem to find any differences, thus the head desk 🙂 I'll keep digging