tip-files 0.1.2

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/edits");
    let _ = fs::remove_dir_all(&root);
    make(s)
}

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

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

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