This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-24
Channels
- # beginners (108)
- # boot (16)
- # bristol-clojurians (1)
- # cider (20)
- # cljs-dev (167)
- # clojure (64)
- # clojure-greece (4)
- # clojure-hamburg (1)
- # clojure-russia (1)
- # clojure-uk (27)
- # clojurescript (235)
- # datomic (1)
- # devops (2)
- # fulcro (80)
- # graphql (6)
- # heroku (2)
- # jobs-discuss (1)
- # jobs-rus (2)
- # lein-figwheel (1)
- # lumo (2)
- # nyc (1)
- # off-topic (22)
- # portkey (4)
- # re-frame (44)
- # reagent (39)
- # ring-swagger (9)
- # shadow-cljs (90)
- # tools-deps (5)
- # vim (8)
- # yada (2)
@jmckitrick I think it’s about simplicity. Closure is a first class concept in FP/Clojure and people (should) understand that already. Custom restructuring is part of a DSL, which is c-api spesific. Also, the closure-based dependencies are resolved at api-creation time, and thus can be used to generate new static routes (generate crud-routes based on tables in the db). Request-time injection is both slower (injecting component into request and extracting them from there), can only create dynamic routes (not seen in swagger) and if the deps are setup incorrectly, it fails at runtime.
@mgrbyte oh, request should be 400 and response 500. Was sure there were tests for this. Could you write an Issue out of this, PR would be nice too 😉
@ikitommi Looking at developing a PR for this now. How do you run tests? I've tried using lein test
... (perhaps that could be in a 'contributing" section of the README or something)
think I've found the right place to change in the tests (test19/spec_coercion-test.clj), can make it fail as expected.
Have tried looking thru the code to find where this is happening, but I'm a bit lost ... I think what's happening is that it only happens for a resource
(which matches my use case) and it seems to be skipping request validation since the test failure (when I annotate it with println is a response validation error:
Loading (compojure.api.coercion.spec-coercion-test)
RESPONSE VAL ERRR: ({:path [:total], :pred clojure.core/pos-int?, :val -4, :via [:compojure.api.coercion.spec-coercion-test/total], :in [:total]})
FAIL "apis - resource - parameters as specs" at (spec_coercion_test.clj:293)
Expected:
400
Actual:
500
I've created an issue here: https://github.com/metosin/compojure-api/issues/373
Will try and look into it more when I have more time, at the moment, I can't see where the code path diverges between a plain GET
route and a resource (for exception handling).
haven’t hear about ‘pact’ before. Looks like basic integration tests? We ported some of the good stuff of Midje to metosin/testit
, which is based on clojure.test
. Have been using that for integration tests. Easy way to do partial asserts on the responses.
@ikitommi I see your point. And I agree language concepts should be favored over app-specific concepts.