1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-14 01:04:11 +00:00
starship/tests/testsuite/conda.rs
Stanisław Barzowski 7c45f74d11
fix: Do not depend on user's config in conda tests (#1098)
The user's config is automatically loaded
in context.new_module. This change explicitly
sets the empty config to avoid depending on
the environment.

Without this fix, the tests do not pass
for users who have a custom symbol defined
for conda. This prevents installing/upgrading
from Arch Linux AUR.
2020-04-13 21:23:49 +02:00

51 lines
1.3 KiB
Rust

use ansi_term::Color;
use std::io;
use crate::common;
use crate::common::TestCommand;
#[test]
fn not_in_env() -> io::Result<()> {
let output = common::render_module("conda")
.env_clear()
.env("PATH", env!("PATH"))
.use_config("".parse().unwrap())
.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_clear()
.env("CONDA_DEFAULT_ENV", "astronauts")
.use_config("".parse().unwrap())
.output()?;
let expected = format!("via {} ", Color::Green.bold().paint("C 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_clear()
.use_config("".parse().unwrap())
.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("C my_env"));
let actual = String::from_utf8(output.stdout).unwrap();
assert_eq!(expected, actual);
Ok(())
}