lens_core/benchmark/
reporting.rs1use serde::{Deserialize, Serialize};
5use anyhow::Result;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
9pub enum ReportFormat {
10 Json,
11 Markdown,
12 Html,
13 Csv,
14}
15
16impl Default for ReportFormat {
17 fn default() -> Self {
18 ReportFormat::Json
19 }
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
24pub enum DetailLevel {
25 Summary,
26 Standard,
27 Detailed,
28 Comprehensive,
29}
30
31impl Default for DetailLevel {
32 fn default() -> Self {
33 DetailLevel::Standard
34 }
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
38pub struct ReportingConfig {
39 pub output_formats: Vec<ReportFormat>,
40 pub detail_level: DetailLevel,
41 pub include_statistical_details: bool,
42 pub include_attestation_details: bool,
43 pub generate_executive_summary: bool,
44 pub include_visualizations: bool,
45 pub include_charts: bool,
46 pub retention_days: u64,
47}
48
49impl Default for ReportingConfig {
50 fn default() -> Self {
51 Self {
52 output_formats: vec![ReportFormat::Json],
53 detail_level: DetailLevel::Standard,
54 include_statistical_details: false,
55 include_attestation_details: false,
56 generate_executive_summary: false,
57 include_visualizations: false,
58 include_charts: false,
59 retention_days: 30,
60 }
61 }
62}
63
64pub struct ReportGenerator {
65 config: ReportingConfig,
66}
67
68impl ReportGenerator {
69 pub fn new(config: ReportingConfig) -> Self {
70 Self { config }
71 }
72
73 pub async fn generate_comprehensive_report(&self) -> Result<Report> {
74 Ok(Report {
76 report_id: "comprehensive-report".to_string(),
77 timestamp: chrono::Utc::now(),
78 sections: vec![],
79 })
80 }
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize)]
84pub struct Report {
85 pub report_id: String,
86 pub timestamp: chrono::DateTime<chrono::Utc>,
87 pub sections: Vec<ReportSection>,
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
91pub struct ReportSection {
92 pub title: String,
93 pub content: String,
94 pub metrics: std::collections::HashMap<String, serde_json::Value>,
95}
96
97#[cfg(test)]
98mod tests {
99 use super::*;
100
101 #[test]
102 fn test_reporting_config_default() {
103 let config = ReportingConfig::default();
104 assert_eq!(config.output_formats.len(), 1);
105 assert!(matches!(config.output_formats[0], ReportFormat::Json));
106 assert!(!config.include_charts);
107 assert_eq!(config.retention_days, 30);
108 }
109
110 #[test]
111 fn test_report_generator_creation() {
112 let config = ReportingConfig::default();
113 let generator = ReportGenerator::new(config);
114 assert_eq!(generator.config.output_formats.len(), 1);
115 assert!(matches!(generator.config.output_formats[0], ReportFormat::Json));
116 }
117
118 #[tokio::test]
119 async fn test_comprehensive_report_generation() {
120 let config = ReportingConfig::default();
121 let generator = ReportGenerator::new(config);
122
123 let result = generator.generate_comprehensive_report().await;
124 assert!(result.is_ok());
125
126 let report = result.unwrap();
127 assert_eq!(report.report_id, "comprehensive-report");
128 assert!(report.sections.is_empty());
129 }
130
131 #[test]
132 fn test_report_section_creation() {
133 let mut metrics = std::collections::HashMap::new();
134 metrics.insert("test_metric".to_string(), serde_json::Value::Number(serde_json::Number::from(42)));
135
136 let section = ReportSection {
137 title: "Test Section".to_string(),
138 content: "Test content".to_string(),
139 metrics,
140 };
141
142 assert_eq!(section.title, "Test Section");
143 assert_eq!(section.content, "Test content");
144 assert_eq!(section.metrics.len(), 1);
145 }
146
147 #[test]
148 fn test_report_creation() {
149 let report = Report {
150 report_id: "test-report".to_string(),
151 timestamp: chrono::Utc::now(),
152 sections: vec![],
153 };
154
155 assert_eq!(report.report_id, "test-report");
156 assert!(report.sections.is_empty());
157 }
158
159 #[test]
160 fn test_custom_reporting_config() {
161 let config = ReportingConfig {
162 output_formats: vec![ReportFormat::Html, ReportFormat::Markdown],
163 detail_level: DetailLevel::Comprehensive,
164 include_statistical_details: true,
165 include_attestation_details: true,
166 generate_executive_summary: true,
167 include_visualizations: true,
168 include_charts: true,
169 retention_days: 90,
170 };
171
172 assert_eq!(config.output_formats.len(), 2);
173 assert!(matches!(config.output_formats[0], ReportFormat::Html));
174 assert!(matches!(config.output_formats[1], ReportFormat::Markdown));
175 assert!(matches!(config.detail_level, DetailLevel::Comprehensive));
176 assert!(config.include_charts);
177 assert_eq!(config.retention_days, 90);
178 }
179}