1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-12-01 09:13:54 +00:00
starship/tests/testsuite/configuration.rs
Neil Kistner 9f70ffb7a7 fix: Lazy load git repo and only run module if not disabled (#306)
A couple of optimizations are done in this PR. One, we now will check config ahead of time to see if a module is disabled before running any module code. Also, we won't try to discover a git repository unless the module requests access to it.
2019-09-09 19:14:38 -04:00

42 lines
1.1 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use ansi_term::Color;
use std::io;
use crate::common::{self, TestCommand};
#[test]
fn char_symbol_configuration() -> io::Result<()> {
let expected = format!("{} ", Color::Green.bold().paint(""));
let output = common::render_module("character")
.use_config(toml::toml! {
[character]
symbol = ""
})
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
assert_eq!(expected, actual);
Ok(())
}
#[test]
fn add_newline_configuration() -> io::Result<()> {
// Start prompt with newline
let default_output = common::render_prompt().output()?;
let actual = String::from_utf8(default_output.stdout).unwrap();
let expected = actual.trim_start();
assert_ne!(actual, expected);
// Start prompt without newline
let output = common::render_prompt()
.use_config(toml::toml! {
add_newline = false
})
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = actual.trim_start();
assert_eq!(expected, actual);
Ok(())
}