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

Expose method for clearing defined fake CharlatanHttpResponseDefinitions #19

Open
mzdm opened this issue Mar 6, 2022 · 2 comments
Open
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mzdm
Copy link

mzdm commented Mar 6, 2022

The map with CharlatanHttpResponseDefinitions is private, I would like to have an exposed method for clearing this map. I would like to use this method in tearDown so I don't have to instantiate Charlatan everytime.

Describe alternatives you've considered
Something like http-mock-adapter package has: https://github.com/lomsa-dev/http-mock-adapter/blob/eff6dc4563e30dcfe6b29bac7f7343567d61bdf6/lib/src/mixins/recording.dart#L42

@mzdm mzdm added the enhancement New feature or request label Mar 6, 2022
@mzdm mzdm changed the title Expose method to clear defined fake CharlatanHttpResponseDefinitions Expose method for clearing defined fake CharlatanHttpResponseDefinitions Mar 6, 2022
@samandmoore samandmoore self-assigned this Mar 6, 2022
@samandmoore
Copy link
Member

hi @mzdm. thanks for filing a feature request.

can you elaborate on why it's important to you not to instantiate a new Charlatan instance for each test?

in general, we prefer to use immutable data structures and objects. Charlatan is mutable mostly to enable better ergonomics in testing: so you don't have to set up all your fake responses far away from your test cases but you can setup dependencies on Charlatan in a shared place.

i'm not entirely opposed to this request, but i'd love to hear a bit more on why it's valuable.

@mzdm
Copy link
Author

mzdm commented Mar 9, 2022

Thanks for the fast feedback! Yes, you're totally right, the best/cleanest scenario is to create a new instance for each test (it was just my laziness).

Now I'm more thinking about that, let's say I would have some long smoke test, would it make sense to have a method for clearing these http definitons during test execution? Let's say I test login-logout-login, to make sure I don't use some fake http definiton from the first login, after logout I would clear all definitons so this will make sure I will need fake them again. Sorry for poor explanation, I hope it makes at least a little bit sense :D

@samandmoore samandmoore added good first issue Good for newcomers help wanted Extra attention is needed labels Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants