venmo / DVR

Network testing for Swift
http://blog.soff.es/network-testing-in-swift-with-dvr
MIT License
651 stars 86 forks source link

Cassette improvements #15

Closed soffes closed 9 years ago

soffes commented 9 years ago

This is a simpler implementation of #5. Not sure that it's better though. If we decide we want to merge this, then I'll write a Ruby script to convert old cassettes to the new format.

If the content type begins with text/ it is included as a string in the JSON encoding of the cassette. If they content type is application/json, the object is included as a nested array or dictionary in the JSON. If it's anything else, we'll continue to base64 encode it (for stuff like images, etc).

This also adds a new line to the end of cassettes :)

dasmer commented 9 years ago

:green_apple:

czechboy0 commented 9 years ago

Hey @soffes, I guess that's fine you closed #5, I'm still not a big fan of breaking/having to migrate old cassettes, that's why I kept that extra key in the request/response dictionary so that DVR always knows how to deserialize it. I guess this is more forward-looking, after we somehow migrate old cassettes (have you created the script to migrate them btw?).

Anyway, you also missed out on a bunch of tests in #5 - those are independent on your/mine implementation, but basically test that all this code you wrote works. I suggest you copy/paste them if you want, because they test all the serialization cases.