-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VCR playback should terminate if it has a response #181
Comments
FYI I don't think the behavior introduced in that commit is correct. I successfully bisected a bug down to it: https://gist.github.com/lvh/9e765f8999cb6d7f5a93a5abbd994588 I'm not 100% sure I identified the bug correctly, but, let's start with observed behavior:
|
I'm also not sure I understand the use case for this behavior: isn't the VCR replaying interceptor supposed to replace the real-HTTP-request-making one, so there's no chance of a real HTTP request being made anyway? Is this change intended to do anything if the user is doing that correctly? FWIW I tried to replace remove-stack with terminate and that did ostensibly fix the issue. I'll create a PR. |
…eptors References oliyh#181. `remove-stack` prevents all further interceptors from running. It uses `terminate` under the hood. Critical difference: `terminate` just means we'd move to the second phase (`:leave`), ensuring things like e.g. response body encoding still happens.
I think I figured out why this failure doesn't occur in the test. Unfortunately, I was unable to debug this particularly closely because I couldn't start a REPL; the issue looks identical to #85 even though it is running in a subdirectory:
I was able to run the tests via (def dummy-response
{:status 200
:headers {"Content-Type" "application/json"}
:body {:foo "bar"}}) Whereas in my production martian-hato project, the HTTP client returns Therefore I think the underlying problem may be a semantic confusion: is the VCR functionality intended to just cover the actual HTTP request part, or is it intended to be at a higher level? I contend it should just do the HTTP bit, and this is an example of why: if I wanted to paper over most of the behavior in martian, I wouldn't need martian-specific VCR functionality. |
There are two use cases in my mind:
Given where it sits, at the end of the interceptor chain, it should persist the "raw" response, i.e. a string body. The playback one will rely on the rest of your interceptor chain being in place to coerce that as json or whatever, which means you can use this as a regression test for your interceptor stack as well. I agree, VCR is just meant to sit at the perform-request, i.e. HTTP level. |
* feat: Update vcr.cljc to use tripod.context instead of martian.interceptors References #181. `remove-stack` prevents all further interceptors from running. It uses `terminate` under the hood. Critical difference: `terminate` just means we'd move to the second phase (`:leave`), ensuring things like e.g. response body encoding still happens. * Test desired behavior explicitly * tc/terminate should engage _after_ the response is determined The :leave phase of our interceptors may well want to modify the response (e.g. to parse the response body) -- in fact, that's one of the most common use cases. * Return an explicit cooked response
VCR playback should terminate if it has a response (whatever it is). This will prevent a real perform-request interceptor from being invoked even if the playback response should have been used.
The text was updated successfully, but these errors were encountered: