use super::{MODE_OPTIONS, magic_note, mode_note, modes_in_effect};
use crate::conflict_side_state::Operation;
use std::ffi::OsString;
#[test]
fn every_mode_option_is_found_in_the_prefix() {
for option in MODE_OPTIONS {
let prefix: Vec<OsString> = vec![OsString::from("-C"), OsString::from("."), OsString::from(option)];
assert_eq!(modes_in_effect(prefix.as_slice(), &[]), vec![String::from(option)], "{option}");
}
assert!(modes_in_effect(&[OsString::from("-C"), OsString::from(".")], &[]).is_empty());
}
#[test]
fn a_variable_in_the_overlay_is_a_mode() {
let overlay: Vec<(OsString, OsString)> = vec![(OsString::from("GIT_GLOB_PATHSPECS"), OsString::from("0"))];
assert_eq!(modes_in_effect(&[], overlay.as_slice()), vec![String::from("GIT_GLOB_PATHSPECS")]);
}
#[test]
fn the_notes_name_the_mode_or_the_magic_and_the_way_out() {
let mode: String = mode_note(&[String::from("--icase-pathspecs")], Operation::Rebase);
assert!(mode.contains("This rebase is in progress") && mode.contains("the same command without `--icase-pathspecs`"), "{mode}");
assert!(mode.contains("saved first and then allowed"), "{mode}");
let magic: String = magic_note(&[(String::from(":(icase)"), String::from("sub/a.rs"))], Operation::Revert);
assert!(magic.contains("This revert is in progress") && magic.contains("`:(icase)`") && magic.contains("`sub/a.rs`"), "{magic}");
assert!(magic.contains("saved first and then allowed"), "{magic}");
}