mirror of
https://github.com/starship/starship.git
synced 2026-06-22 02:02:12 +07:00
Add nix-shell support (#173)
This commit is contained in:
committed by
Matan Kushner
parent
57e807fec6
commit
feb737190e
@@ -7,6 +7,7 @@ mod golang;
|
||||
mod jobs;
|
||||
mod line_break;
|
||||
mod modules;
|
||||
mod nix_shell;
|
||||
mod nodejs;
|
||||
mod python;
|
||||
mod ruby;
|
||||
|
||||
@@ -0,0 +1,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(())
|
||||
}
|
||||
Reference in New Issue
Block a user