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