2019-10-05 18:25:25 +00:00
|
|
|
use ansi_term::Color;
|
|
|
|
use std::io;
|
|
|
|
|
2020-07-30 16:57:15 +00:00
|
|
|
use crate::common::{self, TestCommand};
|
2019-10-05 18:25:25 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn not_in_env() -> io::Result<()> {
|
2020-07-07 22:45:32 +00:00
|
|
|
let output = common::render_module("conda").output()?;
|
2019-10-05 18:25:25 +00:00
|
|
|
|
|
|
|
let expected = "";
|
|
|
|
let actual = String::from_utf8(output.stdout).unwrap();
|
|
|
|
|
|
|
|
assert_eq!(expected, actual);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2020-07-30 16:57:15 +00:00
|
|
|
#[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(())
|
|
|
|
}
|
|
|
|
|
2019-10-05 18:25:25 +00:00
|
|
|
#[test]
|
|
|
|
fn env_set() -> io::Result<()> {
|
|
|
|
let output = common::render_module("conda")
|
|
|
|
.env("CONDA_DEFAULT_ENV", "astronauts")
|
|
|
|
.output()?;
|
|
|
|
|
2020-07-07 22:45:32 +00:00
|
|
|
let expected = format!("via {} ", Color::Green.bold().paint("🅒 astronauts"));
|
2019-10-05 18:25:25 +00:00
|
|
|
let actual = String::from_utf8(output.stdout).unwrap();
|
|
|
|
|
|
|
|
assert_eq!(expected, actual);
|
|
|
|
Ok(())
|
|
|
|
}
|
2019-12-09 17:59:02 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn truncate() -> io::Result<()> {
|
2020-04-13 19:23:49 +00:00
|
|
|
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()?;
|
2019-12-09 17:59:02 +00:00
|
|
|
|
2020-07-07 22:45:32 +00:00
|
|
|
let expected = format!("via {} ", Color::Green.bold().paint("🅒 my_env"));
|
2019-12-09 17:59:02 +00:00
|
|
|
let actual = String::from_utf8(output.stdout).unwrap();
|
|
|
|
|
|
|
|
assert_eq!(expected, actual);
|
|
|
|
Ok(())
|
|
|
|
}
|