#![deny(missing_docs)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
pub struct Task {
pub number: usize,
pub title: String,
pub status: Status,
pub remaining_work: Option<u8>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ProjectTasks {
pub project_name: String,
pub tasks: Vec<Task>,
}
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
pub enum Status {
Todo,
Doing,
Done,
}
impl Task {
pub fn new(number: usize, title: &str) -> Self {
Task {
number,
title: String::from(title),
status: Status::Todo,
remaining_work: None,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn new_should_set_status_to_todo() {
assert_eq!(Task::new(1, "").status, Status::Todo);
}
#[test]
fn new_should_not_set_remaining_work() {
assert_eq!(Task::new(1, "").remaining_work, None);
}
}