Skip to content

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

Closed

Conversation

szabgab
Copy link
Contributor

@szabgab szabgab commented Mar 31, 2025

No description provided.

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Mar 31, 2025
@szabgab
Copy link
Contributor Author

szabgab commented Apr 6, 2025

@ehuss It would be nice if you could accept this so I can start writing other tests based on the empty temporary folder.

/// 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> {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Comment on lines 28 to 40
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());
Copy link
Contributor

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?

Copy link
Contributor Author

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?

@szabgab szabgab force-pushed the test/check-more-details-in-cli-test branch from 6424815 to 3ca2b5a Compare April 20, 2025 09:03
@ehuss
Copy link
Contributor

ehuss commented Apr 25, 2025

I'm going to close as superseded by #2676, which now validates the full output of the init command and the files it generates.

@ehuss ehuss closed this Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: waiting on a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants