summaryrefslogtreecommitdiffstats
path: root/tests/testsuite/directory.rs
diff options
context:
space:
mode:
authorNeil Kistner <neil.kistner@gmail.com>2019-08-26 20:52:45 -0500
committerMatan Kushner <hello@matchai.me>2019-08-26 21:52:45 -0400
commite034253a5eea764b20ab601f71bf84903d80e8d6 (patch)
tree96f653a6c20f0f6c9a8a7ad9f3d6e984aa89251d /tests/testsuite/directory.rs
parent81ea165cecab575bba60c093f5a088f18bbe7d18 (diff)
feat: Add ability to use an alternate directory truncation style (#239)
* Add ability to use an alternate directory truncation style
Diffstat (limited to 'tests/testsuite/directory.rs')
-rw-r--r--tests/testsuite/directory.rs133
1 files changed, 133 insertions, 0 deletions
diff --git a/tests/testsuite/directory.rs b/tests/testsuite/directory.rs
index 702a6b516..dce7f7983 100644
--- a/tests/testsuite/directory.rs
+++ b/tests/testsuite/directory.rs
@@ -62,6 +62,28 @@ fn truncated_directory_in_home() -> io::Result<()> {
}
#[test]
+#[ignore]
+fn fish_directory_in_home() -> io::Result<()> {
+ let dir = home_dir().unwrap().join("starship/engine/schematics");
+ fs::create_dir_all(&dir)?;
+
+ let output = common::render_module("directory")
+ .use_config(toml::toml! {
+ [directory]
+ truncation_length = 1
+ fish_style_pwd_dir_length = 2
+ })
+ .arg("--path")
+ .arg(dir)
+ .output()?;
+ let actual = String::from_utf8(output.stdout).unwrap();
+
+ let expected = format!("in {} ", Color::Cyan.bold().paint("~/st/en/schematics"));
+ assert_eq!(expected, actual);
+ Ok(())
+}
+
+#[test]
fn root_directory() -> io::Result<()> {
let output = common::render_module("directory")
.arg("--path=/")
@@ -143,6 +165,31 @@ fn truncated_directory_config_large() -> io::Result<()> {
#[test]
#[ignore]
+fn fish_style_directory_config_large() -> io::Result<()> {
+ let dir = Path::new("/tmp/starship/thrusters/rocket");
+ fs::create_dir_all(&dir)?;
+
+ let output = common::render_module("directory")
+ .use_config(toml::toml! {
+ [directory]
+ truncation_length = 1
+ fish_style_pwd_dir_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)?;
@@ -164,6 +211,28 @@ fn truncated_directory_config_small() -> io::Result<()> {
#[test]
#[ignore]
+fn fish_directory_config_small() -> io::Result<()> {
+ let dir = Path::new("/tmp/starship/thrusters/rocket");
+ fs::create_dir_all(&dir)?;
+
+ let output = common::render_module("directory")
+ .use_config(toml::toml! {
+ [directory]
+ truncation_length = 2
+ fish_style_pwd_dir_length = 1
+ })
+ .arg("--path")
+ .arg(dir)
+ .output()?;
+ let actual = String::from_utf8(output.stdout).unwrap();
+
+ let expected = format!("in {} ", Color::Cyan.bold().paint("/t/s/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
@@ -257,6 +326,70 @@ fn directory_in_git_repo_truncate_to_repo_false() -> io::Result<()> {
#[test]
#[ignore]
+fn fish_path_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
+ fish_style_pwd_dir_length = 1
+ })
+ .arg("--path")
+ .arg(dir)
+ .output()?;
+ let actual = String::from_utf8(output.stdout).unwrap();
+
+ let expected = format!(
+ "in {} ",
+ Color::Cyan
+ .bold()
+ .paint("~/.t/above-repo/rocket-controls/src/meters/fuel-gauge")
+ );
+ assert_eq!(expected, actual);
+ Ok(())
+}
+
+#[test]
+#[ignore]
+fn fish_path_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
+ fish_style_pwd_dir_length = 1
+ })
+ .arg("--path")
+ .arg(dir)
+ .output()?;
+ let actual = String::from_utf8(output.stdout).unwrap();
+
+ let expected = format!(
+ "in {} ",
+ Color::Cyan
+ .bold()
+ .paint("~/.t/a/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");