1pub mod db;
2pub mod models;
3
4pub use db::*;
5pub use models::*;
6
7#[cfg(test)]
8mod tests {
9 use super::*;
10 use chrono::Utc;
11 use uuid::Uuid;
12
13 #[tokio::test]
14 async fn test_test_run_creation() {
15 let test_run = TestRun {
16 id: Uuid::new_v4(),
17 name: "Test Run".to_string(),
18 image: "test:latest".to_string(),
19 commands: vec!["echo".to_string(), "hello".to_string()],
20 status: "pending".to_string(),
21 created_at: Utc::now(),
22 definition_id: None,
23 executor_id: None,
24 suite_id: None,
25 variables: None,
26 artifacts: None,
27 duration: None,
28 retries: None,
29 logs: None,
30 k8s_job_name: None,
31 pod_scheduled: None,
32 container_created: None,
33 container_started: None,
34 completed: None,
35 failed: None,
36 };
37
38 assert_eq!(test_run.name, "Test Run");
39 assert_eq!(test_run.status, "pending");
40 assert!(!test_run.commands.is_empty());
41 }
42
43 #[test]
44 fn test_test_definition_creation() {
45 let definition = TestDefinition {
46 id: Uuid::new_v4(),
47 name: "Test Definition".to_string(),
48 description: "A test definition".to_string(),
49 image: "test:latest".to_string(),
50 commands: vec!["echo".to_string(), "hello".to_string()],
51 created_at: Utc::now(),
52 executor_id: Some("executor-1".to_string()),
53 labels: Some(vec!["test".to_string()]),
54 variables: None,
55 };
56
57 assert_eq!(definition.name, "Test Definition");
58 assert_eq!(definition.description, "A test definition");
59 assert!(!definition.commands.is_empty());
60 }
61
62 #[test]
63 fn test_executor_creation() {
64 let executor = Executor {
65 id: "executor-1".to_string(),
66 name: "Test Executor".to_string(),
67 description: Some("A test executor".to_string()),
68 image: "test:latest".to_string(),
69 command: Some(vec!["echo".to_string()]),
70 supported_file_types: Some(vec!["json".to_string()]),
71 env: None,
72 created_at: Utc::now(),
73 };
74
75 assert_eq!(executor.name, "Test Executor");
76 assert!(executor.description.is_some());
77 assert_eq!(executor.image, "test:latest");
78 }
79}