Questions for tests on the `--readme` flag
Closed this issue · 0 comments
Atreyagaurav commented
Not really a issue but more of a question here:
So I can add the id on readme contents like:
@if readme.is_some() {
div id="readme" {
h3 id="readme-filename" { (readme.as_ref().unwrap().filename) }
div id="readme-contents" {
(PreEscaped (readme.unwrap().contents));
}
}
}
Now I can test for the presence of those id in the document body, for example:
#[rstest]
/// Do not show readme contents unless told to
fn hide_readme_contents(server: TestServer) -> Result<(), Error> {
let body = reqwest::blocking::get(server.url())?.error_for_status()?;
let parsed = Document::from_read(body)?;
assert!(parsed.find(Attr("id", "readme")).next().is_none());
assert!(parsed.find(Attr("id", "readme-filename")).next().is_none());
assert!(parsed.find(Attr("id", "readme-contents")).next().is_none());
Ok(())
}
This one seems straightforward enough, problem now I'm facing is, how do I simulate the contents of a directory with readme.md
file?
Do I have to make some files in the tests directory, include it in git, and then use them as args in the cli? Or can I just create dummy files in the code itself??
EDIT: I read the fixures module and saw the testdir
has the files with contents, so I used it while also adding readme.md
file with some contents in all the directories.