venmo / DVR

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

Fix Interaction to record HTTP headers and status codes #78

Closed elliottwilliams closed 6 years ago

elliottwilliams commented 6 years ago

I just started using this library today, but I think I hit a small bug in Interaction: I was unable to save the status code and response headers when recording. Here's what I found:

When finished recording, Session.persist calls down to Interaction.dictionary, which checks if response is a HTTPURLResponse. If it is, it records the headers and status code for the response:

if let httpResponse = response as? HTTPURLResponse { …

However, this is checking if the response is a DVR.HTTPURLResponse, not a Foundation.HTTPURLResponse. Since DVR.HTTPURLResponse is only get initialized from cassette dictionaries, this condition should never be true.

I changed HTTPURLResponse to Foundation.HTTPURLResponse and was able to record status code / headers successfully.

Testing

Confirmed that this doesn't affect existing tests.

sethhoward commented 6 years ago

Still an issue, but been done. https://github.com/venmo/DVR/pull/75/

elliottwilliams commented 6 years ago

Got it, thanks for merging #75!