#[cfg(all(
    feature = "cache",
    feature = "core",
    feature = "db",
    feature = "discovery",
    feature = "observability",
    feature = "resil",
    feature = "rest",
    feature = "rpc"
))]
use std::time::Duration;

#[cfg(all(
    feature = "cache",
    feature = "core",
    feature = "db",
    feature = "discovery",
    feature = "observability",
    feature = "resil",
    feature = "rest",
    feature = "rpc"
))]
use rs_zero::{cache, core, db, discovery, observability, resil, rest, rpc};

mod support;

#[cfg(all(
    feature = "cache",
    feature = "core",
    feature = "db",
    feature = "discovery",
    feature = "observability",
    feature = "resil",
    feature = "rest",
    feature = "rpc"
))]
#[test]
fn default_facade_exports_runtime_modules() {
    let _ = core::LogConfig::default();
    let _ = rest::RestConfig::default();
    let _ = rpc::RpcServerConfig::new("hello-rpc", "127.0.0.1:50051".parse().expect("addr"));
    let _ = resil::CircuitBreaker::new(1, Duration::from_millis(1));
    let _ = cache::MemoryCacheStore::new();
    let _ = cache::LruCacheStore::new(8).expect("lru cache");
    let _ = discovery::RoundRobinSelector::default();
    let _ = observability::MetricsConfig::default();
    let _ = db::DatabaseConfig::default();
}

#[test]
fn manifest_declares_provider_features_without_default_heavy_dependencies() {
    let manifest = std::fs::read_to_string("Cargo.toml").expect("read Cargo.toml");
    support::assert_contains_all(
        &manifest,
        &[
            "name = \"rs-zero\"",
            "db-sqlite = [\"db\", \"sqlx/sqlite\"]",
            "db-postgres = [\"db\", \"sqlx/postgres\"]",
            "db-mysql = [\"db\", \"sqlx/mysql\"]",
            "cache = [\"dep:async-trait\", \"dep:serde\", \"dep:serde_json\", \"dep:thiserror\", \"dep:tokio\"]",
            "cache-redis = [\"cache\", \"resil\", \"dep:redis\", \"dep:sha1_smol\", \"dep:uuid\"]",
            "discovery-etcd = [\"discovery\", \"dep:etcd-client\"]",
            "discovery-kube = [\"discovery\", \"dep:kube\", \"dep:k8s-openapi\", \"dep:tokio-stream\", \"k8s-openapi/v1_30\"]",
            "otlp = [\"observability\"",
            "default = [\"core\", \"rest\", \"rpc\", \"resil\", \"cache\", \"discovery\", \"observability\", \"db-sqlite\"]",
        ],
    );
}
