//! Feature flag testing module
//!
//! This module is for testing feature-flag-gated code paths.
//! The code in this module is not meant to be executed directly,
//! but to test that feature flag combinations compile correctly.

// We include this module only in test builds
#[cfg(test)]
mod tests {
    // Test JWT auth feature
    #[cfg(feature = "jwt_auth")]
    #[test]
    #[allow(deprecated)]
    fn test_jwt_auth_compiles() {
        // Just a compilation test
        use crate::jwt_auth::JwtAuthLayer;
        use crate::jwt_auth::RouterJwtExt;
        use axum::{Router, routing::get};
        use serde::{Deserialize, Serialize};

        #[derive(Debug, Serialize, Deserialize, Clone)]
        struct TestClaims {
            sub: String,
        }

        // Test with type parameter
        let _app1: Router<()> = Router::new().with_jwt::<TestClaims>("secret".to_string());

        // Test with default parameter
        let _app2: Router<()> = Router::new().with_jwt::<serde_json::Value>("secret".to_string());

        // Test with layer directly
        // Provide explicit route type to avoid type inference issues
        let router: Router<()> = Router::new().route("/", get(|| async { "Hello" }));
        let _app3 = router.layer(JwtAuthLayer::<TestClaims>::new("secret".to_string()));
    }

    // Test builder feature
    #[cfg(feature = "builder")]
    #[test]
    fn test_builder_compiles() {
        use crate::AppState;
        use crate::secret_client::SecretClient;
        use std::sync::Arc;

        #[derive(Clone)]
        #[allow(dead_code)]
        struct TestFeatures {
            database: bool,
            cache: bool,
            #[allow(dead_code)]
            custom_feature: bool,
        }

        #[derive(Clone)]
        struct TestState {
            #[allow(dead_code)]
            value: String,
        }

        let client = Arc::new(SecretClient::new_dummy());
        let state = TestState {
            value: "test".to_string(),
        };

        let _app_state = AppState::builder()
            .with_module_id("test".to_string())
            .with_orchestrator_api("http://localhost".to_string())
            .with_secret_client(client)
            .with_custom(state);

        // Not calling build() as it would require real instances
    }

    // Test router extensions feature
    #[cfg(feature = "router_ext")]
    #[test]
    fn test_router_ext_compiles() {
        use crate::ext::RouterExt;
        use axum::Router;

        // Specify the state type parameter explicitly to resolve type annotations 
        let router: Router<()> = Router::new();
        #[cfg(feature = "cors")]
        let _with_cors = router.with_cors_preflight();
    }

    // Additional feature tests can be added here as needed
}
