-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
[recorder] add option to load cassette from embed.Fs #83
base: v3
Are you sure you want to change the base?
Conversation
} | ||
|
||
// LoadFromFs reads a cassette file from embedded filesystem | ||
func LoadFromFs(name string, fs embed.FS) (*Cassette, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps one function that takes io.Reader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using io.Reader
makes sense here to simplify things. On the other hand it will introduce a breaking change, so we'll have to careful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep both public func signatures, but make the internal implementation use the io.Reader
to reduce duplication
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you have that loadFromReader
internal implementation, you can remove the switches that you have further down, I think
Hey @johnshiver , Thanks for the PR! I'll try to review it tomorrow and provide some feedback. Thanks again! |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## v3 #83 +/- ##
==========================================
- Coverage 77.69% 73.61% -4.08%
==========================================
Files 1 1
Lines 278 326 +48
==========================================
+ Hits 216 240 +24
- Misses 48 72 +24
Partials 14 14
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Describe your changes
I want a way to load fixtures from an embedded filesystem, so I can use the recorder for my integration tests but also to create fakes that I use while my process is running (development / sandbox mode / etc)
This PR adds an option to create a recorder with an embedded filesystem, and if set optionally loads the cassette from it.
I didn't spend much time making the code nice, it is a little messy for my taste but it does work. If there is support for the idea Im happy to make any adjustments necessary to get the PR merged.
Checklist before requesting a review
tests pass