diff options
author | Saghm Rossi <saghmrossi@gmail.com> | 2019-08-16 23:29:22 -0400 |
---|---|---|
committer | Kevin Song <chipbuster@users.noreply.github.com> | 2019-08-16 20:29:22 -0700 |
commit | 84c394e7b054391e07a571b713816d7d357e7c75 (patch) | |
tree | b5f14484f2977396f79706917f96fce7e306c2ad /tests/testsuite/directory.rs | |
parent | d065dff695b22fe04d56b89f45a1550bdd93c303 (diff) |
feat: Add option to control git directory truncation (#165)
Diffstat (limited to 'tests/testsuite/directory.rs')
-rw-r--r-- | tests/testsuite/directory.rs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/testsuite/directory.rs b/tests/testsuite/directory.rs index 7bbafe9b2..05ac33707 100644 --- a/tests/testsuite/directory.rs +++ b/tests/testsuite/directory.rs @@ -207,3 +207,65 @@ fn truncated_directory_in_git_repo() -> io::Result<()> { assert_eq!(expected, actual); Ok(()) } + +#[test] +#[ignore] +fn directory_in_git_repo_truncate_to_repo_false() -> io::Result<()> { + let tmp_dir = TempDir::new_in(dirs::home_dir().unwrap())?; + let repo_dir = tmp_dir.path().join("above-repo").join("rocket-controls"); + let dir = repo_dir.join("src/meters/fuel-gauge"); + fs::create_dir_all(&dir)?; + Repository::init(&repo_dir).unwrap(); + + let output = common::render_module("directory") + .use_config(toml::toml! { + [directory] + // Don't truncate the path at all. + truncation_length = 5 + truncate_to_repo = false + }) + .arg("--path") + .arg(dir) + .output()?; + let actual = String::from_utf8(output.stdout).unwrap(); + + let expected = format!( + "in {} ", + Color::Cyan + .bold() + .paint("above-repo/rocket-controls/src/meters/fuel-gauge") + ); + assert_eq!(expected, actual); + Ok(()) +} + +#[test] +#[ignore] +fn directory_in_git_repo_truncate_to_repo_true() -> io::Result<()> { + let tmp_dir = TempDir::new_in(dirs::home_dir().unwrap())?; + let repo_dir = tmp_dir.path().join("above-repo").join("rocket-controls"); + let dir = repo_dir.join("src/meters/fuel-gauge"); + fs::create_dir_all(&dir)?; + Repository::init(&repo_dir).unwrap(); + + let output = common::render_module("directory") + .use_config(toml::toml! { + [directory] + // `truncate_to_repo = true` should display the truncated path + truncation_length = 5 + truncate_to_repo = true + }) + .arg("--path") + .arg(dir) + .output()?; + let actual = String::from_utf8(output.stdout).unwrap(); + + let expected = format!( + "in {} ", + Color::Cyan + .bold() + .paint("rocket-controls/src/meters/fuel-gauge") + ); + assert_eq!(expected, actual); + Ok(()) +} |