summaryrefslogtreecommitdiffstats
path: root/tests/testsuite/conda.rs
blob: f7c2e71c3ce36c80e8b3b0c103f41b75623d3560 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use ansi_term::Color;
use std::io;

use crate::common;

#[test]
fn not_in_env() -> io::Result<()> {
    let output = common::render_module("conda")
        .env_clear()
        .env("PATH", env!("PATH"))
        .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")
        .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().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(())
}