1 use crate::{app_auth::AuthApp, ar_date_format};
2 use chrono::{DateTime, Utc};
3 use serde::{Deserialize, Serialize};
4
5 #[derive(Deserialize, Debug, Serialize)]
6 pub struct Config {
7 pub current_project: Option<Project>,
8 pub current_auth_app: Option<AuthApp>,
9 }
10
11 #[derive(Deserialize, Debug, Serialize)]
12 pub struct Project {
13 pub id: i32,
14 pub name: String,
15 pub description: String,
16 #[serde(with = "ar_date_format")]
17 pub created_at: DateTime<Utc>,
18 #[serde(with = "ar_date_format")]
19 pub updated_at: DateTime<Utc>,
20 }
21 #[derive(Serialize, Debug)]
22 pub struct ProjectCreate {
23 pub name: String,
24 pub description: String,
25 }
26
27 #[cfg(test)]
28 mod tests {
29 use super::*;
30 use serde_json::json;
31 #[test]
32 fn test_project_create() {
33 let project_create = ProjectCreate {
34 name: "test".to_owned(),
35 description: "test".to_owned(),
36 };
37 let json = json!({
38 "name": "test",
39 "description": "test",
40 });
41 assert_eq!(serde_json::to_value(project_create).unwrap(), json);
42 }
43 }