mock_usage/
mock_usage.rs

1//! Mock usage example
2//!
3//! This example demonstrates using mock implementations for testing
4//! without requiring actual Google Calendar or Slack credentials.
5//!
6//! Run with:
7//! ```bash
8//! cargo run --example mock_usage
9//! ```
10
11use lab_resource_manager::{
12    JsonFileIdentityLinkRepository, MockUsageRepository, NotificationRouter,
13    NotifyResourceUsageChangesUseCase, load_config,
14};
15use std::sync::Arc;
16
17#[tokio::main]
18async fn main() -> Result<(), Box<dyn std::error::Error>> {
19    println!("šŸš€ Starting resource usage watcher (mock example)");
20    println!("This example uses mock implementations - no credentials required!\n");
21
22    // Load configuration
23    let config = load_config("config/resources.toml")?;
24
25    // Create identity link repository
26    let identity_repo = Arc::new(JsonFileIdentityLinkRepository::new(
27        "data/identity_links.json".into(),
28    ));
29
30    // Create mock repository and notification router
31    let repository = MockUsageRepository::new();
32    let notifier = NotificationRouter::new(config, identity_repo);
33
34    println!("āœ… Mock repository and notification router initialized");
35
36    // Create use case
37    let usecase = NotifyResourceUsageChangesUseCase::new(repository, notifier).await?;
38
39    // Poll once to demonstrate
40    println!("šŸ“Š Polling for changes...\n");
41    usecase.poll_once().await?;
42
43    println!("\nāœ… Example completed successfully!");
44    println!("šŸ’” Note: Mock repository returns empty results by default.");
45    println!(
46        "   To see actual notifications, configure mock notifications in config/resources.toml"
47    );
48
49    Ok(())
50}