fix: Failing Tests if home is a git directory (#214)

This commit is contained in:
Kevin Song 2019-08-21 09:37:43 -07:00 committed by GitHub
parent faa2280620
commit da86b4f847
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -70,6 +70,8 @@ Unit tests are written using the built-in Rust testing library in the same file
Unit tests should be fully isolated, only testing a given function's expected output given a specific input, and should be reproducible on any machine. Unit tests should not expect the computer running them to be in any particular state. This includes having any applications pre-installed, having any environment variables set, etc.
The previous point should be emphasized: even seemingly innocuous ideas like "if we can see the directory, we can read it" or "nobody will have their home directory be a git repo" have bitten us in the past. Having even a single test fail can completely break installation on some platforms, so be careful with tests!
### Acceptance Testing
Acceptance tests are located in the [`tests/`](tests) directory and are also written using the built-in Rust testing library.

View File

@ -12,6 +12,10 @@ use crate::common::{self, TestCommand};
fn home_directory() -> io::Result<()> {
let output = common::render_module("directory")
.arg("--path=~")
.use_config(toml::toml! { // Necessary if homedir is a git repo
[directory]
truncate_to_repo = false
})
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();