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

into_persistent(_if) documentation confusion #90

Closed
ericcornelissen opened this issue Feb 11, 2023 · 2 comments
Closed

into_persistent(_if) documentation confusion #90

ericcornelissen opened this issue Feb 11, 2023 · 2 comments

Comments

@ericcornelissen
Copy link

The documentation for .into_persistent (and .into_persistent_if) suggest you can delete a persisted TempDir by calling .close on it.

/// ```no_run
/// use assert_fs::fixture::TempDir;
///
/// let tmp_dir = TempDir::new()
/// .unwrap()
/// .into_persistent();
///
/// // Ensure deletion happens.
/// tmp_dir.close().unwrap();
/// ```

However, the implementation of .close explicitly doesn't do anything when the TempDir has been persisted.

Inner::Persisted(_) => (),

So, either

  1. the documentation example should be updated to clarify a persisted TempDir can't be deleted, or
  2. the implementation of .close should be updated to remove persisted TempDir`.

Some background

I ran into this while trying to work around #51 by trying to persist-by-default and close/delete on success.

@epage
Copy link
Contributor

epage commented Feb 13, 2023

I removed that copy/paste documentation bug in d5c06c6

@epage epage closed this as completed Feb 13, 2023
@epage
Copy link
Contributor

epage commented Feb 13, 2023

btw you might find snapbox::path::PathFixture of interest. The only thing it is missing compared to higher level stuff like trycmd is support for an env variable to control the behavior.

I personally have replaced all my uses of assert_cmd / assert_fs with snapbox.

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

No branches or pull requests

2 participants