-
Notifications
You must be signed in to change notification settings - Fork 18
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
In snapbox, impl From<PathBuf> for Data
?
#254
Comments
Wanted to double check first: is it a path that could use the My main concern is that I wonder if there are other options for shortening this, like a function you can pull in. |
These are relative paths, where I have some base directory I'm working with and then I didn't know that |
Could you share the code?
|
Sure, there are a ton of tests set up like this. There's a data directory for each test which contains the files to operate on in their initial state, as well as their expected state after running the command. It also has text files with snapshots of stdout/stderr. I'm open to any advice you have for making these tests more maintainable 😁. I only just discovered |
So it looks like the code is generally organized as:
In Cargo, we have it organized as
See https://github.com/rust-lang/cargo/tree/master/tests/testsuite/cargo_add/build_prefer_existing_version as an example This is maybe a bit extreme where you have one test case per The intention behind the API changes include
None of this is to say "you are doing it wrong" but to explore the space and see what options, on both sides, look like.
Something I've been considering is having something like Unsure if anything in this direction could help with your testing or have ideas for where else to take it. |
Wow, thanks so much for the detailed advice 😍! I was already starting to tinker with a more standard setup for tests to avoid boilerplate, and that Because my tests mostly follow a standard pattern, I also was able to make a relatively simple API for tests to leverage, which looks something like this: TestCase::new(file!())
.git(&[
Commit("Initial commit"),
Tag("v1.0.0"),
Commit("feat: New feature in existing release"),
Tag("v1.1.0"),
Commit("feat!: Breaking feature in new RC"),
])
.env("KNOPE_PRERELEASE_LABEL", "alpha")
.run("prerelease"); And the |
I'm working on upgrading to snapbox 0.5, and the new method of comparing an output to a file in the path seems to require more boilerplate. Instead of
.stdout_matches_path(my_path)
, I now need to do.stdout_matches(Data::read_from(&my_path, None))
.What do you think about implementing both
From<&Path>
andFrom<PathBuf>
for data to remove that extra boilerplate?If there is another, cleaner method already, please let me know! 😁
The text was updated successfully, but these errors were encountered: