You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What this would bring over using the existing copy_from() for a single file is the ability to copy the file to a different name. Basically I'd like the semantics of write_binary() and write_str() but using an existing file as source.
use assert_fs::prelude::*;let temp = assert_fs::TempDir::new().unwrap();
temp
.child("input.txt").write_file("unittest.42.txt").unwrap();
temp.close().unwrap();
The rationale is that my program uses fixed names for various input files (and/or I don't want to bother configuring my program to use other filenames), but I have many different input files for as many different unittests. I want to say "for this test, the content of input.txt will be taken from that example file".
The text was updated successfully, but these errors were encountered:
The workaround seems to be fs::copy(Path::new(".").join(src), tempdir.path().join(dst)), which is arguably simple enough. But it feels weird to not be able to use assert_fs directly for this.
Thanks for using assert_fs and letting me know about this! I definitely see the value in this. Besides the ability to rename, this just in general is simpler than having to use copy_from which I think would be worthwhile.
What this would bring over using the existing
copy_from()
for a single file is the ability to copy the file to a different name. Basically I'd like the semantics ofwrite_binary()
andwrite_str()
but using an existing file as source.The rationale is that my program uses fixed names for various input files (and/or I don't want to bother configuring my program to use other filenames), but I have many different input files for as many different unittests. I want to say "for this test, the content of input.txt will be taken from that example file".
The text was updated successfully, but these errors were encountered: