relay-knowledge 1.1.16

Graph-database-based knowledge graph project.
Documentation
//! Direct tests for watcher runtime configuration.

use super::*;

#[test]
fn default_config_has_sensible_defaults() {
    let config = WatcherConfig::default();
    assert!(config.enabled);
    assert_eq!(config.debounce, Duration::from_secs(3));
    assert_eq!(config.commit_reconcile_interval, Duration::from_secs(5));
    assert_eq!(config.max_watch_dirs, 1024);
    assert_eq!(config.hash_cache_capacity, 4096);
}

#[test]
fn from_environment_applies_overrides() {
    let overrides = crate::env::WatcherEnvOverrides {
        enabled: Some(false),
        debounce_ms: Some(5000),
        commit_reconcile_interval_ms: Some(7000),
        max_watch_dirs: Some(2048),
        hash_cache_capacity: Some(8192),
    };
    let config = WatcherConfig::from_environment(&overrides);
    assert!(!config.enabled);
    assert_eq!(config.debounce, Duration::from_millis(5000));
    assert_eq!(
        config.commit_reconcile_interval,
        Duration::from_millis(7000)
    );
    assert_eq!(config.max_watch_dirs, 2048);
    assert_eq!(config.hash_cache_capacity, 8192);
}

#[test]
fn from_environment_uses_defaults_when_no_overrides() {
    let overrides = crate::env::WatcherEnvOverrides::default();
    let config = WatcherConfig::from_environment(&overrides);
    assert!(config.enabled);
    assert_eq!(config.debounce, Duration::from_secs(3));
    assert_eq!(config.commit_reconcile_interval, Duration::from_secs(5));
    assert_eq!(config.max_watch_dirs, 1024);
    assert_eq!(config.hash_cache_capacity, 4096);
}