pedestal

Karol Wójcik 2020-05-15T08:03:56.102Z

Imo faking the request should be considered bad practice. Why do people test whether http library like pedestal works? Shouldn't we test the domain logic instead?

jdkealy 2020-05-15T14:46:17.103800Z

That’s my issue is because of all the chained interceptors (I’m brand new to pedestal and interceptors ), I don’t understand how to get the result of an endpoint without using response-for

2020-05-15T14:47:03.104500Z

@jdkealy you can also test an interceptor or subset of interceptors directly

jdkealy 2020-05-15T14:48:37.105900Z

Let’s say I wanted to get a swagger.json from <https://github.com/oliyh/pedestal-api/blob/master/src/pedestal_api/swagger.clj#L10> and upload it to S3. Would you be able to do that without using response-for ?

jdkealy 2020-05-15T14:50:03.106200Z

That calls this: <https://github.com/frankiesardo/route-swagger/blob/master/src/route_swagger/interceptor.clj#L21>

2020-05-15T14:52:16.108700Z

IDK, that’s less of a pedestal concern. While working in the repl during development I don’t use response-for . I limit the usage to testing. In the repl I work with small fns which handle the core logic of the system

2020-05-15T14:53:14.109300Z

I don’t think end-to-end testing is bad practice but it should not be applied as a hammer either.

2020-05-15T14:54:43.110800Z

I also tend to spin up my service and send requests to it during dev as well. Changes being applied as I build. But I do that when I’m interested in any wiring I’ve done

2020-05-15T14:55:08.111200Z

When working on interceptors, I’m most interested in Context in/out

2020-05-15T14:55:27.111600Z

So can exercise them in isolation

2020-05-15T14:56:16.112500Z

If an interceptor requires some setup (i.e., data in context) I either fake that or add the interceptors that bring in that data to the interceptor chain that gets executed

2020-05-15T14:57:15.113300Z

(def result-ctx (io.pedestal.interceptor.chain/execute {} [interceptor1 interceptor2 …])

2020-05-15T14:57:18.113500Z

something like that

2020-05-15T15:00:50.115200Z

The concept of Chain Provider is at the core of Pedestal http://pedestal.io/reference/chain-providers#chain-providers

2020-05-15T15:01:39.115800Z

@jdkealy glad to see you giving Pedestal a spin! Hopefully this info helps.

jdkealy 2020-05-15T15:01:50.116Z

Thanks a bunch 🙂