Fork me on GitHub
#reitit
<
2018-03-29
>
grierson13:03:57

How do I test each individual branch (reitit/ring)? For example I have def app (ring/ring-handler (ring/router ["/api" branch1 branch2 branch3])) each branch are just clojure vectors as reitit routes. In my test for branchN do I have to require [app] then test from the top down to that route OR do I create a ring-handler within my test for those routes and test that handler?

ikitommi15:03:51

@grierson we test all routes via the whole application. Usually there is data & middleware attached to the top-level and they would not be in place if the sub-routes were tested separately. Actually, I think we mostly against a live server. e.g. a fixture sets up the system using a random http-port and we ram in real requests. This tests the JSON/Transit/EDN encoders & decoders too.

ikitommi15:03:30

But if you are careful, you can test the individual routes too, just wrap ’em into a ring-handler.

grierson15:03:43

Ok, thank you.

ikitommi15:03:07

As middleware & interceptors can be decide not to mount themselves for a given route, there is no perf penalty to mount them into root.