tip-files 0.1.0

Tickets in project
Documentation
use std::{fs, path::PathBuf};

use tip_files::Tips;

fn make_new<'a>(s: &'a mut Vec<u8>) -> Tips<'a> {
    let root = PathBuf::from("tests/status");
    let _ = fs::remove_dir_all(&root);
    make(s)
}

fn make<'a>(s: &'a mut Vec<u8>) -> Tips<'a> {
    let root = PathBuf::from("tests/status");
    fs::create_dir_all(PathBuf::from("tests/status/open")).unwrap();
    fs::create_dir_all(PathBuf::from("tests/status/closed")).unwrap();
    Tips::new(root, s)
}

#[test]
fn test_status() {
    let mut s = Vec::new();
    let mut tips = make_new(&mut s);
    tips.create("ticket");
    let res = str::from_utf8(&s).unwrap();
    assert_eq!(res, "1 (open): ticket\n");

    s.clear();
    let mut tips = make(&mut s);
    tips.close("1");
    tips.details("1");
    let res = str::from_utf8(&s).unwrap();
    assert_eq!(res, "1 (closed): ticket\n");

    s.clear();
    let mut tips = make(&mut s);
    tips.open("1");
    tips.details("1");
    let res = str::from_utf8(&s).unwrap();
    assert_eq!(res, "1 (open): ticket\n");
}