mirror of
https://github.com/starship/starship.git
synced 2026-06-23 02:05:51 +07:00
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:
committed by
Matan Kushner
parent
ab46710fc4
commit
5dbf4381ac
@@ -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<()> {
|
||||
|
||||
Reference in New Issue
Block a user