feat: Allow directory truncation length to be configured (#120)

This allows the directory truncation length to be configured. Previously, it was hard-coded to truncate to 3 parent directories.
This commit is contained in:
Andrew Dassonville
2019-07-28 18:05:13 -07:00
committed by Matan Kushner
parent ab46710fc4
commit 5dbf4381ac
5 changed files with 109 additions and 6 deletions
+46 -1
View File
@@ -6,7 +6,7 @@ use std::io;
use std::path::Path;
use tempfile::TempDir;
use crate::common;
use crate::common::{self, TestCommand};
#[test]
fn home_directory() -> io::Result<()> {
@@ -95,6 +95,51 @@ fn truncated_directory_in_root() -> io::Result<()> {
Ok(())
}
#[test]
#[ignore]
fn truncated_directory_config_large() -> io::Result<()> {
let dir = Path::new("/tmp/starship/thrusters/rocket");
fs::create_dir_all(&dir)?;
let output = common::render_module("dir")
.use_config(toml::toml! {
[directory]
truncation_length = 100
})
.arg("--path")
.arg(dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = format!(
"in {} ",
Color::Cyan.bold().paint("/tmp/starship/thrusters/rocket")
);
assert_eq!(expected, actual);
Ok(())
}
#[test]
#[ignore]
fn truncated_directory_config_small() -> io::Result<()> {
let dir = Path::new("/tmp/starship/thrusters/rocket");
fs::create_dir_all(&dir)?;
let output = common::render_module("dir")
.use_config(toml::toml! {
[directory]
truncation_length = 2
})
.arg("--path")
.arg(dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = format!("in {} ", Color::Cyan.bold().paint("thrusters/rocket"));
assert_eq!(expected, actual);
Ok(())
}
#[test]
#[ignore]
fn git_repo_root() -> io::Result<()> {