mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-25 06:07:43 +00:00
9f70ffb7a7
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.
42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
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(())
|
||
}
|