summaryrefslogtreecommitdiffstats
path: root/tests/testsuite/directory.rs
diff options
context:
space:
mode:
authorAndrew Dassonville <dassonville.andrew@gmail.com>2019-07-28 18:05:13 -0700
committerMatan Kushner <hello@matchai.me>2019-07-28 21:05:13 -0400
commit5dbf4381acd1fd8dbb2905828c3fcc6515d850cf (patch)
tree36a13ea34b8af9c0f6c5fa30c8ae9d7c3835f0de /tests/testsuite/directory.rs
parentab46710fc47891a80eb1b6073616c95a1acc92bd (diff)
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.
Diffstat (limited to 'tests/testsuite/directory.rs')
-rw-r--r--tests/testsuite/directory.rs47
1 files changed, 46 insertions, 1 deletions
diff --git a/tests/testsuite/directory.rs b/tests/testsuite/directory.rs
index c2c81d52f..1a5e67ddc 100644
--- a/tests/testsuite/directory.rs
+++ b/tests/testsuite/directory.rs
@@ -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<()> {
@@ -97,6 +97,51 @@ fn truncated_directory_in_root() -> io::Result<()> {
#[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<()> {
// TODO: Investigate why git repo related tests fail when the tempdir is within /tmp/...
// Temporarily making the tempdir within $HOME