-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Read several passwords from reader #46
Comments
@dvermd Thanks for your suggestion! We could totally do this, although it would require a bit of trickery to not break code without proper upgrade path. So before we get into that, I have a question. In your tests, what is the reason for re-using the same reader instead of creating a brand new one for each test? Is it because you call |
The function I'd like to test is something like
And I was trying to change it to something like
which does not compile. I'm working on a testing solution that will work without changing rpassword code.
I don't yet wrote the struct for testing purpose, it'll be a struct implementing the Bufferize trait We may hold this issue for some time until I come up with a working solution. Then either change the rpassword code or add an example. |
@dvermd Thanks for explaining in such detail 👍 I'm all for integrating the changes you suggested in the first place. That'll make testing way easier. So if you make a PR for that, I'll be happy to merge. Here's how we'd go about integrating those changes all the while minimizing upgrade effort for existing users:
This will allow people to have the following simple upgrade path:
This means we need 2 PRs:
Would that be OK with you ? |
@dvermd Another option would be to simply add a new function to fit your needs, I'm not sure if that makes a lot of sense though. From your explanation, I'm not sure how the current signature allows for much testing, even though we added this function specifically to enable easier testing, from what I remember. |
@conradkleinespel The upgrate path you describe seems fine to me. Users would have to update their code twice but they'll have time to manage thess updates. Another way to add this change is to add a feature or a cfg flag. This way existing users would continue to use the current API and new ones or those willing to add mock to their code can enable the feature. Once we're OK on the way to add this, I'll give a try at implementing it. |
Here is a draft PR with the feature option to discuss about the principle. It may get completely reworked if it's not the option you choose. |
@conradkleinespel I'm facing a problem with There's another way to add tests without changing rpassword API by adding an indirection in the caller's code. With these examples, there's another way to close this issue. |
The changes have been merged ✔️ |
For testing purpose, I'm migrating calls from
prompt_password_stdout
toread_password_with_reader
. I'm facing a problem with the signaturewhich "consumes" the
BufRead
and doesn't make it possible to be called several times with the same reader.Would you consider changing the signature to
instead ?
The text was updated successfully, but these errors were encountered: