This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-08
Channels
- # announcements (2)
- # aws (1)
- # beginners (134)
- # calva (26)
- # cider (48)
- # cljdoc (41)
- # cljs-dev (12)
- # clojure (178)
- # clojure-brasil (1)
- # clojure-europe (16)
- # clojure-italy (30)
- # clojure-nl (13)
- # clojure-spec (118)
- # clojure-uk (81)
- # clojurescript (209)
- # community-development (77)
- # cursive (7)
- # datomic (23)
- # duct (6)
- # emacs (15)
- # events (2)
- # figwheel (13)
- # figwheel-main (18)
- # fulcro (4)
- # jackdaw (4)
- # jobs (6)
- # jobs-discuss (6)
- # kaocha (2)
- # lein-figwheel (3)
- # off-topic (4)
- # other-languages (22)
- # pathom (2)
- # pedestal (9)
- # perun (10)
- # portkey (1)
- # re-frame (41)
- # reagent (6)
- # reitit (4)
- # remote-jobs (1)
- # ring-swagger (6)
- # rum (5)
- # shadow-cljs (300)
- # sql (3)
- # test-check (6)
- # testing (7)
- # vim (1)
- # yada (9)
Hi #pedestal users, I am in need of guidance regarding the function below
(defn create-servlet
"Creates a servlet given an options map with keyword keys prefixed by namespace e.g.
:io.pedestal.http/interceptors or ::bootstrap/interceptors if the namespace is aliased to bootstrap.
Options:
* :io.pedestal.http/interceptors: A vector of interceptors that defines a service.
Note: Additional options are passed to default-interceptors if :interceptors is not set."
[service-map]
(-> service-map
default-interceptors
service-fn
servlet))
I am looking at some legacy code that is exercising this function in order to create a test servlet, but that seems to be opposed to this guide -> http://pedestal.io/guides/pedestal-with-componentCan somebody help me understand what is this pattern of use of create-servlet
?
@ariel.silverman it’s common to use response-for
to test your service implementation. That constructs a servlet request under the covers which is used to exercise your implementation.
@U0FL657GR - Would you be open to helping me out with this subject? I wasn’t really able to find any good resources…
@ariel.silverman sure! Here’s a start. A new pedestal project created via the pedestal-service template contains some initial tests. Here’s a trimmed down version of one of those tests in the ‘Hello World’ sample: https://github.com/pedestal/pedestal/blob/master/samples/hello-world/test/hello_world/service_test.clj#L19-L25
I’ll work on fleshing out the reference for unit testing in the http://pedestal.io docs.
response-for
can be used to test all HTTP methods. If you are testing :post
you can specify a :body
.
@U0FL657GR thank you for your help 🙂 I will review the project for inspiration and clarification and follow up if any questions arise. Thanks again!