stormchaser_model/test_report.rs
1//! Test reporting and summary models for workflow execution.
2
3use serde::{Deserialize, Serialize};
4use uuid::Uuid;
5
6/// Details of a single test report associated with a step instance.
7#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow)]
8pub struct TestReport {
9 /// Unique identifier for the test report.
10 pub id: Uuid,
11 /// Associated workflow run ID.
12 pub run_id: Uuid,
13 /// Associated step instance ID.
14 pub step_instance_id: Uuid,
15 /// Logical name of the report.
16 pub report_name: String,
17 /// Original file name of the report.
18 pub file_name: String,
19 /// Format of the report (e.g., 'junit', 'clover').
20 pub format: String,
21 /// Raw content of the report, if small enough to be inlined.
22 pub content: Option<String>,
23 /// Storage backend ID where the full report is stored.
24 pub backend_id: Option<Uuid>,
25 /// Path to the report in the remote storage backend.
26 pub remote_path: Option<String>,
27 /// Checksum of the report content.
28 pub checksum: String,
29 /// Timestamp when the report was recorded.
30 pub created_at: chrono::DateTime<chrono::Utc>,
31}
32
33/// Aggregated summary of test results for a specific report.
34#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow, Default)]
35pub struct TestSummary {
36 /// Unique identifier for the summary.
37 pub id: Uuid,
38 /// Associated workflow run ID.
39 pub run_id: Uuid,
40 /// Associated step instance ID.
41 pub step_instance_id: Uuid,
42 /// Logical name of the report.
43 pub report_name: String,
44 /// Total number of tests executed.
45 pub total_tests: i32,
46 /// Number of tests that passed.
47 pub passed: i32,
48 /// Number of tests that failed.
49 pub failed: i32,
50 /// Number of tests that were skipped.
51 pub skipped: i32,
52 /// Number of tests that encountered an error.
53 pub errors: i32,
54 /// Total duration of the test suite execution in milliseconds.
55 pub duration_ms: i64,
56 /// Timestamp when the summary was generated.
57 pub created_at: chrono::DateTime<chrono::Utc>,
58}
59
60/// Status of an individual test case.
61#[derive(Debug, Serialize, Deserialize, Clone, sqlx::Type, PartialEq, Eq)]
62#[sqlx(type_name = "test_case_status", rename_all = "snake_case")]
63#[serde(rename_all = "snake_case")]
64pub enum TestCaseStatus {
65 /// The test case passed successfully.
66 Passed,
67 /// The test case failed.
68 Failed,
69 /// The test case was skipped.
70 Skipped,
71 /// The test case encountered an unexpected error.
72 Error,
73}
74
75/// Details of an individual test case execution.
76#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow)]
77pub struct TestCase {
78 /// Unique identifier for the test case record.
79 pub id: Uuid,
80 /// Associated workflow run ID.
81 pub run_id: Uuid,
82 /// Associated step instance ID.
83 pub step_instance_id: Uuid,
84 /// Logical name of the report containing this test case.
85 pub report_name: String,
86 /// Name of the test suite this case belongs to.
87 pub test_suite: Option<String>,
88 /// Name of the test case.
89 pub test_case: String,
90 /// Final status of the test case execution.
91 pub status: TestCaseStatus,
92 /// Duration of the test case execution in milliseconds.
93 pub duration_ms: Option<i64>,
94 /// Optional error or failure message associated with the test case.
95 pub message: Option<String>,
96 /// Timestamp when the test case record was created.
97 pub created_at: chrono::DateTime<chrono::Utc>,
98}