Open JayBazuzi opened 3 years ago
Hi,
I share this issue.
But I have some interrogation with the "ALL" mode
This can be temporarily used to force VCR to re-record a cassette (i.e. to ensure the responses are not out of date) For me, this means that old records should be overwritten by new records. This is not currently the behavior.
But :
can be used when you simply want to log all HTTP requests means all requests should be recorded...
So I don't know if a good move will be to edit "ALL" mode to erase old record, and append new one. Or add a mode to "rewrite" and juste keep last query.
This would be particularly useful for Dockerized tests that interact with the local filesystem.
If your container contains some cassette mytest.yml
, and you want to completely rewrite it, 'all' won't do the job - it'll append, and you'll end up having to manually trim out the old data.
If you remove the file (locally) and run the test... surprise! Docker shadowed it so you get an appended file again (vexing when you're trying to understand why it's not updating correctly).
A 'replace' mode should entirely ignore the existing cassette and write an entirely new one to the cassette file, eliminating these problems.
From the README:
I want this behavior as a configuration parameter to VCR: I want to set a RecordMode that will replace the existing cassette with fresh new data.
One way this would be useful is when I'm iterating on a filter:
Today this is only possible if I add:
3.5. Delete the correct cassette file
Originally I thought this is what
RecordMode.ALL
might do, but was disappointed to find that it only appends not overwrites. I considered suggesting thatALL
should in fact delete the existing recorded requests, but maybe that's a breaking change that you don't want.