use super::command_tree::{build_command_map, build_command_tree};
use super::completer::get_completions_raw;
use super::hinter::get_hint_raw;
#[test]
fn test_command_tree() {
let commands = build_command_tree();
assert!(!commands.is_empty());
let map = build_command_map(&commands);
assert!(!map.is_empty());
}
#[test]
fn test_command_completions() {
let commands = build_command_tree();
let map = build_command_map(&commands);
let completions = get_completions_raw(&commands, &map, "");
assert!(!completions.is_empty());
let completions = get_completions_raw(&commands, &map, "au");
assert!(completions.iter().any(|(r, _)| r == "auth"));
let completions = get_completions_raw(&commands, &map, "auth ");
assert!(completions.iter().any(|(r, _)| r == "login"));
let completions = get_completions_raw(&commands, &map, "auth log");
assert!(completions.iter().any(|(r, _)| r == "login"));
assert!(completions.iter().any(|(r, _)| r == "logout"));
}
#[test]
fn test_hints() {
let commands = build_command_tree();
let map = build_command_map(&commands);
let hint = get_hint_raw(&commands, &map, "au");
assert!(hint.is_some());
let (display, _) = hint.unwrap();
assert!(display.starts_with("th"));
let hint = get_hint_raw(&commands, &map, "auth ");
assert!(hint.is_some());
let hint = get_hint_raw(&commands, &map, "bucket create ");
assert!(hint.is_some());
let (display, _) = hint.unwrap();
assert!(display.contains("BUCKET_KEY"));
}