-
Notifications
You must be signed in to change notification settings - Fork 1.7k
use empty folder; check more details in result #1568 #2628
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
use empty folder; check more details in result #1568 #2628
Conversation
@ehuss It would be nice if you could accept this so I can start writing other tests based on the empty temporary folder. |
tests/dummy_book/mod.rs
Outdated
/// Write a book to a temporary directory using the provided settings. | ||
pub fn build(&self) -> Result<TempDir> { | ||
let temp = TempFileBuilder::new() | ||
pub fn empty(&self) -> Result<TempDir> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a little out of place, since it is no longer actually building the dummy book. That is, this method doesn't seem associated with the class DummyBook. Is there a reason that a test that needs an empty directory can't just call TempFileBuilder
directly? That is done in quite a few other places. If we really need to shorten that, we can perhaps find a way to share it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now creating the temporary directory directly.
tests/cli/init.rs
Outdated
assert_eq!(config.book.language, Some(String::from("en"))); | ||
assert_eq!(config.book.multilingual, false); | ||
assert_eq!(config.book.src, PathBuf::from("src")); | ||
|
||
assert!(!temp.path().join(".gitignore").exists()); | ||
let summary = read_to_string(temp.path().join("src").join("SUMMARY.md")).unwrap(); | ||
assert_eq!(summary, "# Summary\n\n- [Chapter 1](./chapter_1.md)\n"); | ||
let chapter_1 = read_to_string(temp.path().join("src").join("chapter_1.md")).unwrap(); | ||
assert_eq!(chapter_1, "# Chapter 1\n"); | ||
assert!(temp.path().join("book").exists()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this test is mostly about skipping prompts (and verifying the result of those skipped prompts), perhaps these should be moved to tests/init.rs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can move it there, but this is still a cli-based test so shouldn't it stay in the cli folder?
6424815
to
3ca2b5a
Compare
I'm going to close as superseded by #2676, which now validates the full output of the init command and the files it generates. |
No description provided.