1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-25 06:07:43 +00:00
starship/tests/testsuite/conda.rs
Jason Wang acefbc523f
feat(conda): add ignore_base option (#1539)
* Add ignore_base to conda module

* Add ignore_base to conda module in English docs

* `ignore_base` defaults to `true`
2020-07-30 18:57:15 +02:00

59 lines
1.4 KiB
Rust

use ansi_term::Color;
use std::io;
use crate::common::{self, TestCommand};
#[test]
fn not_in_env() -> io::Result<()> {
let output = common::render_module("conda").output()?;
let expected = "";
let actual = String::from_utf8(output.stdout).unwrap();
assert_eq!(expected, actual);
Ok(())
}
#[test]
fn ignore_base() -> io::Result<()> {
let output = common::render_module("conda")
.env("CONDA_DEFAULT_ENV", "base")
.use_config(toml::toml! {
[conda]
ignore_base = true
})
.output()?;
let expected = "";
let actual = String::from_utf8(output.stdout).unwrap();
assert_eq!(expected, actual);
Ok(())
}
#[test]
fn env_set() -> io::Result<()> {
let output = common::render_module("conda")
.env("CONDA_DEFAULT_ENV", "astronauts")
.output()?;
let expected = format!("via {} ", Color::Green.bold().paint("🅒 astronauts"));
let actual = String::from_utf8(output.stdout).unwrap();
assert_eq!(expected, actual);
Ok(())
}
#[test]
fn truncate() -> io::Result<()> {
let output = common::render_module("conda")
.env("CONDA_DEFAULT_ENV", "/some/really/long/and/really/annoying/path/that/shouldnt/be/displayed/fully/conda/my_env")
.output()?;
let expected = format!("via {} ", Color::Green.bold().paint("🅒 my_env"));
let actual = String::from_utf8(output.stdout).unwrap();
assert_eq!(expected, actual);
Ok(())
}