use std::path::PathBuf;
use tip_files::Tips;
fn make<'a>(s: &'a mut Vec<u8>) -> Tips<'a> {
let root = PathBuf::from("tests/tip");
Tips::new(root, s)
}
#[test]
fn test_list_and_title_open_only() {
let mut s = Vec::new();
let mut tips = make(&mut s);
tips.list(&["open"]);
let s = str::from_utf8(&s).unwrap();
assert_eq!(s, "2 (open): Open ticket\n3 (open): Title only ticket\n");
}
#[test]
fn test_list_and_title_closed_only() {
let mut s = Vec::new();
let mut tips = make(&mut s);
tips.list(&["closed"]);
let s = str::from_utf8(&s).unwrap();
assert_eq!(s, "1 (closed): Done ticket\n11 (closed): Sort testing\n");
}
#[test]
fn test_list_and_title_all() {
let mut s = Vec::new();
let mut tips = make(&mut s);
tips.list(&["open", "closed"]);
let s = str::from_utf8(&s).unwrap();
assert_eq!(
s,
"1 (closed): Done ticket\n2 (open): Open ticket\n3 (open): Title only ticket\n11 (closed): Sort testing\n"
);
}
#[test]
fn test_details_of_empty() {
let mut s = Vec::new();
let mut tips = make(&mut s);
tips.details("");
let s = str::from_utf8(&s).unwrap();
assert_eq!(s, "");
}
#[test]
fn test_details_of_unknown() {
let mut s = Vec::new();
let mut tips = make(&mut s);
tips.details("none");
let s = str::from_utf8(&s).unwrap();
assert_eq!(s, "");
}
#[test]
fn test_details_of_1() {
let mut s = Vec::new();
let mut tips = make(&mut s);
tips.details("1");
let s = str::from_utf8(&s).unwrap();
assert_eq!(s, "1 (closed): Done ticket\n\nOld ticket\n");
}
#[test]
fn test_details_of_2() {
let mut s = Vec::new();
let mut tips = make(&mut s);
tips.details("2");
let s = str::from_utf8(&s).unwrap();
assert_eq!(s, "2 (open): Open ticket\n\nThis is an open ticket\n");
}
#[test]
fn test_details_of_3() {
let mut s = Vec::new();
let mut tips = make(&mut s);
tips.details("3");
let s = str::from_utf8(&s).unwrap();
assert_eq!(s, "3 (open): Title only ticket\n");
}