Skip to content
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

Open
wants to merge 1 commit into
base: v3
Choose a base branch
from

Conversation

johnshiver
Copy link

@johnshiver johnshiver commented Mar 7, 2023

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

}

// LoadFromFs reads a cassette file from embedded filesystem
func LoadFromFs(name string, fs embed.FS) (*Cassette, error) {
Copy link
Author

@johnshiver johnshiver Mar 8, 2023

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

Copy link
Owner

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point

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

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

@dnaeon
Copy link
Owner

dnaeon commented Mar 8, 2023

Hey @johnshiver ,

Thanks for the PR! I'll try to review it tomorrow and provide some feedback. Thanks again!

@codecov-commenter
Copy link

codecov-commenter commented Mar 8, 2023

Codecov Report

Merging #83 (0d189b6) into v3 (035acaf) will decrease coverage by 4.08%.
The diff coverage is 48.43%.

📣 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              
Impacted Files Coverage Δ
recorder/recorder.go 73.61% <48.43%> (-4.08%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants