summaryrefslogtreecommitdiffstats
path: root/tests/testsuite/nix_shell.rs
blob: b278e3cde93e3ee39d93d7bde9df23ee7d09e4d3 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use ansi_term::Color;
use std::io;

use crate::common;

#[test]
fn no_env_variables() -> io::Result<()> {
    let output = common::render_module("nix_shell").output()?;
    let actual = String::from_utf8(output.stdout).unwrap();
    assert_eq!("", actual);
    Ok(())
}

#[test]
fn invalid_env_variables() -> io::Result<()> {
    let output = common::render_module("nix_shell")
        .env("IN_NIX_SHELL", "something_wrong")
        .output()?;
    let actual = String::from_utf8(output.stdout).unwrap();
    assert_eq!("", actual);
    Ok(())
}

#[test]
fn pure_shell() -> io::Result<()> {
    let output = common::render_module("nix_shell")
        .env("IN_NIX_SHELL", "pure")
        .output()?;
    let actual = String::from_utf8(output.stdout).unwrap();

    let expected = format!("via {} ", Color::Red.bold().paint("pure"));
    assert_eq!(expected, actual);
    Ok(())
}

#[test]
fn impure_shell() -> io::Result<()> {
    let output = common::render_module("nix_shell")
        .env("IN_NIX_SHELL", "impure")
        .output()?;
    let actual = String::from_utf8(output.stdout).unwrap();

    let expected = format!("via {} ", Color::Red.bold().paint("impure"));
    assert_eq!(expected, actual);
    Ok(())
}

#[test]
fn lorri_shell() -> io::Result<()> {
    let output = common::render_module("nix_shell")
        .env("IN_NIX_SHELL", "1")
        .output()?;
    let actual = String::from_utf8(output.stdout).unwrap();

    let expected = format!("via {} ", Color::Red.bold().paint("impure"));
    assert_eq!(expected, actual);
    Ok(())
}