mollendorff-forge 10.0.0-beta.8

Battle-tested financial math for AI. 173 Excel-compatible functions validated against Gnumeric & R. MCP integration, Monte Carlo, Decision Trees, Real Options.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
//! API request handlers
//!
//! Handlers for all REST API endpoints.

use std::path::PathBuf;
use std::sync::Arc;

use axum::{extract::State, response::IntoResponse, Json};
use serde::{Deserialize, Serialize};
use uuid::Uuid;

use crate::cli::{
    audit as cli_audit, calculate as cli_calculate, export as cli_export, import as cli_import,
    validate as cli_validate,
};

use super::server::AppState;

/// Standard API response wrapper
#[derive(Serialize)]
pub struct ApiResponse<T> {
    pub success: bool,
    pub request_id: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data: Option<T>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error: Option<String>,
}

impl<T: Serialize> ApiResponse<T> {
    pub fn ok(data: T) -> Self {
        Self {
            success: true,
            request_id: Uuid::new_v4().to_string(),
            data: Some(data),
            error: None,
        }
    }

    pub fn err(message: impl Into<String>) -> Self
    where
        T: Default,
    {
        Self {
            success: false,
            request_id: Uuid::new_v4().to_string(),
            data: None,
            error: Some(message.into()),
        }
    }
}

/// Root endpoint response
#[derive(Serialize)]
pub struct RootResponse {
    pub name: String,
    pub version: String,
    pub description: String,
    pub endpoints: Vec<EndpointInfo>,
}

#[derive(Serialize)]
pub struct EndpointInfo {
    pub path: String,
    pub method: String,
    pub description: String,
}

/// GET / - Root info
pub async fn root(State(state): State<Arc<AppState>>) -> impl IntoResponse {
    let response = RootResponse {
        name: "Forge API Server".to_string(),
        version: state.version.clone(),
        description: "Enterprise HTTP API for YAML formula calculations".to_string(),
        endpoints: vec![
            EndpointInfo {
                path: "/health".to_string(),
                method: "GET".to_string(),
                description: "Health check endpoint".to_string(),
            },
            EndpointInfo {
                path: "/version".to_string(),
                method: "GET".to_string(),
                description: "Get server version".to_string(),
            },
            EndpointInfo {
                path: "/api/v1/validate".to_string(),
                method: "POST".to_string(),
                description: "Validate a YAML model file".to_string(),
            },
            EndpointInfo {
                path: "/api/v1/calculate".to_string(),
                method: "POST".to_string(),
                description: "Calculate formulas in a YAML model".to_string(),
            },
            EndpointInfo {
                path: "/api/v1/audit".to_string(),
                method: "POST".to_string(),
                description: "Audit a variable's dependency tree".to_string(),
            },
            EndpointInfo {
                path: "/api/v1/export".to_string(),
                method: "POST".to_string(),
                description: "Export YAML to Excel".to_string(),
            },
            EndpointInfo {
                path: "/api/v1/import".to_string(),
                method: "POST".to_string(),
                description: "Import Excel to YAML".to_string(),
            },
        ],
    };
    Json(ApiResponse::ok(response))
}

/// Health check response
#[derive(Serialize)]
pub struct HealthResponse {
    pub status: String,
    pub uptime_message: String,
}

/// GET /health - Health check
pub async fn health() -> impl IntoResponse {
    Json(ApiResponse::ok(HealthResponse {
        status: "healthy".to_string(),
        uptime_message: "Server is running".to_string(),
    }))
}

/// Version response
#[derive(Serialize)]
pub struct VersionResponse {
    pub version: String,
    pub features: Vec<String>,
}

/// GET /version - Server version
pub async fn version(State(state): State<Arc<AppState>>) -> impl IntoResponse {
    Json(ApiResponse::ok(VersionResponse {
        version: state.version.clone(),
        features: vec![
            "validate".to_string(),
            "calculate".to_string(),
            "audit".to_string(),
            "export".to_string(),
            "import".to_string(),
        ],
    }))
}

/// Validate request
#[derive(Deserialize)]
pub struct ValidateRequest {
    pub file_path: String,
}

/// Validate response
#[derive(Serialize, Default)]
pub struct ValidateResponse {
    pub valid: bool,
    pub file_path: String,
    pub message: String,
}

/// POST /api/v1/validate - Validate a YAML model
pub async fn validate(Json(req): Json<ValidateRequest>) -> impl IntoResponse {
    let path = PathBuf::from(&req.file_path);

    match cli_validate(&[path]) {
        Ok(()) => Json(ApiResponse::ok(ValidateResponse {
            valid: true,
            file_path: req.file_path,
            message: "Validation successful".to_string(),
        })),
        Err(e) => Json(ApiResponse::ok(ValidateResponse {
            valid: false,
            file_path: req.file_path,
            message: e.to_string(),
        })),
    }
}

/// Calculate request
#[derive(Deserialize)]
pub struct CalculateRequest {
    pub file_path: String,
    #[serde(default)]
    pub dry_run: bool,
}

/// Calculate response
#[derive(Serialize, Default)]
pub struct CalculateResponse {
    pub calculated: bool,
    pub file_path: String,
    pub dry_run: bool,
    pub message: String,
}

/// POST /api/v1/calculate - Calculate formulas
pub async fn calculate(Json(req): Json<CalculateRequest>) -> impl IntoResponse {
    let path = PathBuf::from(&req.file_path);
    let dry_run = req.dry_run;

    match cli_calculate(&path, dry_run, false, None) {
        Ok(()) => Json(ApiResponse::ok(CalculateResponse {
            calculated: true,
            file_path: req.file_path,
            dry_run,
            message: if dry_run {
                "Dry run completed".to_string()
            } else {
                "Calculation completed and file updated".to_string()
            },
        })),
        Err(e) => Json(ApiResponse::ok(CalculateResponse {
            calculated: false,
            file_path: req.file_path,
            dry_run,
            message: format!("Error: {e}"),
        })),
    }
}

/// Audit request
#[derive(Deserialize)]
pub struct AuditRequest {
    pub file_path: String,
    pub variable: String,
}

/// Audit response
#[derive(Serialize, Default)]
pub struct AuditResponse {
    pub audited: bool,
    pub file_path: String,
    pub variable: String,
    pub message: String,
}

/// POST /api/v1/audit - Audit a variable
pub async fn audit(Json(req): Json<AuditRequest>) -> impl IntoResponse {
    let path = PathBuf::from(&req.file_path);
    let variable = req.variable.clone();

    match cli_audit(&path, &variable) {
        Ok(()) => Json(ApiResponse::ok(AuditResponse {
            audited: true,
            file_path: req.file_path,
            variable,
            message: "Audit completed".to_string(),
        })),
        Err(e) => Json(ApiResponse::ok(AuditResponse {
            audited: false,
            file_path: req.file_path,
            variable,
            message: format!("Error: {e}"),
        })),
    }
}

/// Export request
#[derive(Deserialize)]
pub struct ExportRequest {
    pub yaml_path: String,
    pub excel_path: String,
}

/// Export response
#[derive(Serialize, Default)]
pub struct ExportResponse {
    pub exported: bool,
    pub yaml_path: String,
    pub excel_path: String,
    pub message: String,
}

/// POST /api/v1/export - Export YAML to Excel
pub async fn export(Json(req): Json<ExportRequest>) -> impl IntoResponse {
    let yaml_path = PathBuf::from(&req.yaml_path);
    let excel_path = PathBuf::from(&req.excel_path);

    match cli_export(&yaml_path, &excel_path, false) {
        Ok(()) => Json(ApiResponse::ok(ExportResponse {
            exported: true,
            yaml_path: req.yaml_path,
            excel_path: req.excel_path,
            message: "Export completed".to_string(),
        })),
        Err(e) => Json(ApiResponse::ok(ExportResponse {
            exported: false,
            yaml_path: req.yaml_path,
            excel_path: req.excel_path,
            message: format!("Error: {e}"),
        })),
    }
}

/// Import request
#[derive(Deserialize)]
pub struct ImportRequest {
    pub excel_path: String,
    pub yaml_path: String,
}

/// Import response
#[derive(Serialize, Default)]
pub struct ImportResponse {
    pub imported: bool,
    pub excel_path: String,
    pub yaml_path: String,
    pub message: String,
}

/// POST /api/v1/import - Import Excel to YAML
pub async fn import_excel(Json(req): Json<ImportRequest>) -> impl IntoResponse {
    let excel_path = PathBuf::from(&req.excel_path);
    let yaml_path = PathBuf::from(&req.yaml_path);

    match cli_import(&excel_path, &yaml_path, false, false, false) {
        Ok(()) => Json(ApiResponse::ok(ImportResponse {
            imported: true,
            excel_path: req.excel_path,
            yaml_path: req.yaml_path,
            message: "Import completed".to_string(),
        })),
        Err(e) => Json(ApiResponse::ok(ImportResponse {
            imported: false,
            excel_path: req.excel_path,
            yaml_path: req.yaml_path,
            message: format!("Error: {e}"),
        })),
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    // ==================== ApiResponse Tests ====================

    #[test]
    fn test_api_response_ok_creates_success_response() {
        let response: ApiResponse<String> = ApiResponse::ok("test data".to_string());

        assert!(response.success);
        assert_eq!(response.data, Some("test data".to_string()));
        assert!(response.error.is_none());
        assert!(!response.request_id.is_empty());
        // Verify UUID format (8-4-4-4-12)
        assert_eq!(response.request_id.len(), 36);
    }

    #[test]
    fn test_api_response_ok_with_struct() {
        let health = HealthResponse {
            status: "healthy".to_string(),
            uptime_message: "running".to_string(),
        };
        let response = ApiResponse::ok(health);

        assert!(response.success);
        assert!(response.data.is_some());
        let data = response.data.unwrap();
        assert_eq!(data.status, "healthy");
        assert_eq!(data.uptime_message, "running");
    }

    #[test]
    fn test_api_response_err_creates_error_response() {
        let response: ApiResponse<String> = ApiResponse::err("Something went wrong");

        assert!(!response.success);
        assert!(response.data.is_none());
        assert_eq!(response.error, Some("Something went wrong".to_string()));
        assert!(!response.request_id.is_empty());
    }

    #[test]
    fn test_api_response_request_id_is_unique() {
        let response1: ApiResponse<String> = ApiResponse::ok("test1".to_string());
        let response2: ApiResponse<String> = ApiResponse::ok("test2".to_string());

        assert_ne!(response1.request_id, response2.request_id);
    }

    // ==================== Response Struct Default Tests ====================

    #[test]
    fn test_validate_response_default() {
        let response = ValidateResponse::default();

        assert!(!response.valid);
        assert!(response.file_path.is_empty());
        assert!(response.message.is_empty());
    }

    #[test]
    fn test_calculate_response_default() {
        let response = CalculateResponse::default();

        assert!(!response.calculated);
        assert!(!response.dry_run);
        assert!(response.file_path.is_empty());
        assert!(response.message.is_empty());
    }

    #[test]
    fn test_audit_response_default() {
        let response = AuditResponse::default();

        assert!(!response.audited);
        assert!(response.file_path.is_empty());
        assert!(response.variable.is_empty());
        assert!(response.message.is_empty());
    }

    #[test]
    fn test_export_response_default() {
        let response = ExportResponse::default();

        assert!(!response.exported);
        assert!(response.yaml_path.is_empty());
        assert!(response.excel_path.is_empty());
        assert!(response.message.is_empty());
    }

    #[test]
    fn test_import_response_default() {
        let response = ImportResponse::default();

        assert!(!response.imported);
        assert!(response.excel_path.is_empty());
        assert!(response.yaml_path.is_empty());
        assert!(response.message.is_empty());
    }

    // ==================== Request Deserialization Tests ====================

    #[test]
    fn test_validate_request_deserialize() {
        let json = r#"{"file_path": "model.yaml"}"#;
        let req: ValidateRequest = serde_json::from_str(json).unwrap();

        assert_eq!(req.file_path, "model.yaml");
    }

    #[test]
    fn test_calculate_request_deserialize_with_dry_run() {
        let json = r#"{"file_path": "model.yaml", "dry_run": true}"#;
        let req: CalculateRequest = serde_json::from_str(json).unwrap();

        assert_eq!(req.file_path, "model.yaml");
        assert!(req.dry_run);
    }

    #[test]
    fn test_calculate_request_deserialize_dry_run_defaults_false() {
        let json = r#"{"file_path": "model.yaml"}"#;
        let req: CalculateRequest = serde_json::from_str(json).unwrap();

        assert_eq!(req.file_path, "model.yaml");
        assert!(!req.dry_run);
    }

    #[test]
    fn test_audit_request_deserialize() {
        let json = r#"{"file_path": "model.yaml", "variable": "total_revenue"}"#;
        let req: AuditRequest = serde_json::from_str(json).unwrap();

        assert_eq!(req.file_path, "model.yaml");
        assert_eq!(req.variable, "total_revenue");
    }

    #[test]
    fn test_export_request_deserialize() {
        let json = r#"{"yaml_path": "model.yaml", "excel_path": "output.xlsx"}"#;
        let req: ExportRequest = serde_json::from_str(json).unwrap();

        assert_eq!(req.yaml_path, "model.yaml");
        assert_eq!(req.excel_path, "output.xlsx");
    }

    #[test]
    fn test_import_request_deserialize() {
        let json = r#"{"excel_path": "input.xlsx", "yaml_path": "output.yaml"}"#;
        let req: ImportRequest = serde_json::from_str(json).unwrap();

        assert_eq!(req.excel_path, "input.xlsx");
        assert_eq!(req.yaml_path, "output.yaml");
    }

    // ==================== Response Serialization Tests ====================

    #[test]
    fn test_health_response_serialize() {
        let response = HealthResponse {
            status: "healthy".to_string(),
            uptime_message: "Server is running".to_string(),
        };
        let json = serde_json::to_string(&response).unwrap();

        assert!(json.contains("\"status\":\"healthy\""));
        assert!(json.contains("\"uptime_message\":\"Server is running\""));
    }

    #[test]
    fn test_version_response_serialize() {
        let response = VersionResponse {
            version: "2.0.0".to_string(),
            features: vec!["validate".to_string(), "calculate".to_string()],
        };
        let json = serde_json::to_string(&response).unwrap();

        assert!(json.contains("\"version\":\"2.0.0\""));
        assert!(json.contains("\"features\":[\"validate\",\"calculate\"]"));
    }

    #[test]
    fn test_validate_response_serialize() {
        let response = ValidateResponse {
            valid: true,
            file_path: "model.yaml".to_string(),
            message: "Validation successful".to_string(),
        };
        let json = serde_json::to_string(&response).unwrap();

        assert!(json.contains("\"valid\":true"));
        assert!(json.contains("\"file_path\":\"model.yaml\""));
        assert!(json.contains("\"message\":\"Validation successful\""));
    }

    #[test]
    fn test_calculate_response_serialize() {
        let response = CalculateResponse {
            calculated: true,
            file_path: "model.yaml".to_string(),
            dry_run: false,
            message: "Calculation completed".to_string(),
        };
        let json = serde_json::to_string(&response).unwrap();

        assert!(json.contains("\"calculated\":true"));
        assert!(json.contains("\"dry_run\":false"));
    }

    #[test]
    fn test_api_response_serializes_without_none_fields() {
        let response: ApiResponse<String> = ApiResponse::ok("data".to_string());
        let json = serde_json::to_string(&response).unwrap();

        // error field should be skipped when None
        assert!(!json.contains("\"error\""));
        assert!(json.contains("\"success\":true"));
        assert!(json.contains("\"data\":\"data\""));
    }

    #[test]
    fn test_api_response_error_serializes_without_data() {
        let response: ApiResponse<String> = ApiResponse::err("error message");
        let json = serde_json::to_string(&response).unwrap();

        // data field should be skipped when None
        assert!(!json.contains("\"data\""));
        assert!(json.contains("\"success\":false"));
        assert!(json.contains("\"error\":\"error message\""));
    }

    // ==================== EndpointInfo Tests ====================

    #[test]
    fn test_endpoint_info_serialize() {
        let info = EndpointInfo {
            path: "/api/v1/validate".to_string(),
            method: "POST".to_string(),
            description: "Validate a YAML model".to_string(),
        };
        let json = serde_json::to_string(&info).unwrap();

        assert!(json.contains("\"path\":\"/api/v1/validate\""));
        assert!(json.contains("\"method\":\"POST\""));
        assert!(json.contains("\"description\":\"Validate a YAML model\""));
    }

    #[test]
    fn test_root_response_has_all_endpoints() {
        let response = RootResponse {
            name: "Forge API Server".to_string(),
            version: "2.0.0".to_string(),
            description: "Enterprise HTTP API".to_string(),
            endpoints: vec![
                EndpointInfo {
                    path: "/health".to_string(),
                    method: "GET".to_string(),
                    description: "Health check".to_string(),
                },
                EndpointInfo {
                    path: "/api/v1/validate".to_string(),
                    method: "POST".to_string(),
                    description: "Validate".to_string(),
                },
            ],
        };

        assert_eq!(response.endpoints.len(), 2);
        assert_eq!(response.endpoints[0].path, "/health");
        assert_eq!(response.endpoints[1].path, "/api/v1/validate");
    }

    // ==================== Async Handler Tests ====================

    #[tokio::test]
    async fn test_health_handler() {
        use axum::response::IntoResponse;

        let response = health().await;
        let response = response.into_response();

        assert_eq!(response.status(), axum::http::StatusCode::OK);
    }

    #[tokio::test]
    async fn test_version_handler() {
        use axum::response::IntoResponse;

        let state = Arc::new(AppState {
            version: "5.0.0".to_string(),
        });

        let response = version(State(state)).await;
        let response = response.into_response();

        assert_eq!(response.status(), axum::http::StatusCode::OK);
    }

    #[tokio::test]
    async fn test_root_handler() {
        use axum::response::IntoResponse;

        let state = Arc::new(AppState {
            version: "5.0.0".to_string(),
        });

        let response = root(State(state)).await;
        let response = response.into_response();

        assert_eq!(response.status(), axum::http::StatusCode::OK);
    }

    #[tokio::test]
    async fn test_validate_handler_nonexistent_file() {
        use axum::response::IntoResponse;

        let req = ValidateRequest {
            file_path: "/nonexistent/file.yaml".to_string(),
        };

        let response = validate(Json(req)).await;
        let response = response.into_response();

        // Should return 200 with error in body (API convention)
        assert_eq!(response.status(), axum::http::StatusCode::OK);
    }

    #[tokio::test]
    async fn test_validate_handler_valid_file() {
        use axum::response::IntoResponse;

        let req = ValidateRequest {
            file_path: "test-data/budget.yaml".to_string(),
        };

        let response = validate(Json(req)).await;
        let response = response.into_response();

        assert_eq!(response.status(), axum::http::StatusCode::OK);
    }

    #[tokio::test]
    async fn test_calculate_handler_dry_run() {
        use axum::response::IntoResponse;

        let req = CalculateRequest {
            file_path: "test-data/budget.yaml".to_string(),
            dry_run: true,
        };

        let response = calculate(Json(req)).await;
        let response = response.into_response();

        assert_eq!(response.status(), axum::http::StatusCode::OK);
    }

    #[tokio::test]
    async fn test_calculate_handler_nonexistent() {
        use axum::response::IntoResponse;

        let req = CalculateRequest {
            file_path: "/nonexistent/file.yaml".to_string(),
            dry_run: true,
        };

        let response = calculate(Json(req)).await;
        let response = response.into_response();

        assert_eq!(response.status(), axum::http::StatusCode::OK);
    }

    #[tokio::test]
    async fn test_audit_handler() {
        use axum::response::IntoResponse;

        let req = AuditRequest {
            file_path: "test-data/budget.yaml".to_string(),
            variable: "profit".to_string(),
        };

        let response = audit(Json(req)).await;
        let response = response.into_response();

        assert_eq!(response.status(), axum::http::StatusCode::OK);
    }

    #[tokio::test]
    async fn test_audit_handler_nonexistent() {
        use axum::response::IntoResponse;

        let req = AuditRequest {
            file_path: "/nonexistent/file.yaml".to_string(),
            variable: "test".to_string(),
        };

        let response = audit(Json(req)).await;
        let response = response.into_response();

        assert_eq!(response.status(), axum::http::StatusCode::OK);
    }

    #[tokio::test]
    async fn test_export_handler() {
        use axum::response::IntoResponse;
        use tempfile::TempDir;

        let temp_dir = TempDir::new().unwrap();
        let output_path = temp_dir.path().join("test_export.xlsx");

        let req = ExportRequest {
            yaml_path: "test-data/budget.yaml".to_string(),
            excel_path: output_path.to_string_lossy().to_string(),
        };

        let response = export(Json(req)).await;
        let response = response.into_response();

        assert_eq!(response.status(), axum::http::StatusCode::OK);
    }

    #[tokio::test]
    async fn test_export_handler_nonexistent() {
        use axum::response::IntoResponse;

        let req = ExportRequest {
            yaml_path: "/nonexistent/file.yaml".to_string(),
            excel_path: "/tmp/test.xlsx".to_string(),
        };

        let response = export(Json(req)).await;
        let response = response.into_response();

        assert_eq!(response.status(), axum::http::StatusCode::OK);
    }

    #[tokio::test]
    async fn test_import_handler_nonexistent() {
        use axum::response::IntoResponse;

        let req = ImportRequest {
            excel_path: "/nonexistent/file.xlsx".to_string(),
            yaml_path: "/tmp/test.yaml".to_string(),
        };

        let response = import_excel(Json(req)).await;
        let response = response.into_response();

        assert_eq!(response.status(), axum::http::StatusCode::OK);
    }
}