taskboard_core_lib/
project.rs

1#![deny(missing_docs)]
2use serde::{Deserialize, Serialize};
3use uuid::Uuid;
4
5/// Projects are used to group tasks
6#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
7pub struct Project {
8    /// Unique identifier
9    pub id: Uuid,
10    /// Friendly name
11    pub name: String,
12    /// The total number of tasks created for this project
13    pub task_conter: usize,
14}
15
16impl Project {
17    /// Creates a new project
18    pub fn new(name: &str) -> Self {
19        Project {
20            id: Uuid::new_v4(),
21            name: String::from(name),
22            task_conter: 0,
23        }
24    }
25}
26
27#[cfg(test)]
28mod tests {
29    use super::*;
30
31    #[test]
32    fn new_should_set_task_counter_to_zero() {
33        assert_eq!(Project::new("learn rust").task_conter, 0);
34    }
35
36    #[test]
37    fn new_should_use_unique_ids() {
38        assert_ne!(Project::new("").id, Project::new("").id);
39    }
40}