feat: wire relay API with dependency injection
- split settings module into per-struct files
- add DatabaseSettings with default in-memory SQLite path
- implement RelayApi struct with GET /relays and POST
/relays/{id}/toggle
- wire create_relay_controller and create_label_repository into
Application::build() with mock/real selection via cfg!(test) || CI
- register RelayApi in OpenApiService alongside existing APIs
This commit is contained in:
@@ -427,7 +427,10 @@ async fn test_repository_error_handling() {
|
||||
|
||||
// Test with invalid relay ID (should be caught by domain validation)
|
||||
let invalid_relay_id = RelayId::new(9); // This will fail validation
|
||||
assert!(invalid_relay_id.is_err(), "Invalid relay ID should fail validation");
|
||||
assert!(
|
||||
invalid_relay_id.is_err(),
|
||||
"Invalid relay ID should fail validation"
|
||||
);
|
||||
|
||||
// Test with invalid label (should be caught by domain validation)
|
||||
let invalid_label = RelayLabel::new("".to_string()); // Empty label
|
||||
@@ -444,7 +447,7 @@ async fn test_concurrent_operations_are_thread_safe() {
|
||||
// Since SqliteRelayLabelRepository doesn't implement Clone, we'll test
|
||||
// sequential operations which still verify the repository handles
|
||||
// multiple operations correctly
|
||||
|
||||
|
||||
// Save multiple labels sequentially
|
||||
let relay_id1 = RelayId::new(1).expect("Valid relay ID");
|
||||
let label1 = RelayLabel::new("Task1".to_string()).expect("Valid label");
|
||||
@@ -470,4 +473,4 @@ async fn test_concurrent_operations_are_thread_safe() {
|
||||
.await
|
||||
.expect("get_all_labels should succeed");
|
||||
assert_eq!(all_labels.len(), 3, "Should have all 3 labels");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user