#[cfg(test)]
mod tests {
    use super::*;
    use axum::body::Body;
    use axum::http::{Request, StatusCode};
    use axum::routing::post;
    use axum::Router;
    use common_contracts::registry::{ProviderMetadata, ConfigFieldSchema, FieldType, ServiceRole};
    use crate::state::AppState;
    use tower::ServiceExt; // for `oneshot`
    use std::sync::{Arc, RwLock};
    use std::collections::HashMap;

    // Mock AppState for testing registry logic
    // Since AppState has complex fields like NatsClient, we might mock the registry part only
    // or create a minimal AppState if possible.
    // However, AppState fields are public, but NatsClient is hard to mock.
    // Instead, we can test the logic via direct registry manipulation or by mocking the whole AppState if possible.
    
    // Actually, we can't easily mock NatsClient. 
    // But the registry handlers only need `state.registry`.
    // Let's see if we can construct a dummy AppState or if we should split the registry logic into a trait/struct that is easier to test.
    
    // A better approach for unit testing `registry.rs` handlers is to just test the `RegistryEntry` logic directly 
    // if we can't easily instantiate AppState.
    // BUT the user asked for unit tests for the *module* discovery/revocation.
    
    // Let's try to instantiate a "partial" AppState if we can, or just refactor `registry` to be more testable.
    // Since `AppState` has `nats_client` which connects on creation, it's hard to `AppState::new`.
    // However, we can construct `AppState` manually if fields are pub, but `nats_client` is not optional.
    
    // WORKAROUND: We will test the logic by mocking the "Registry" interactions if we extracted it, 
    // but since it's embedded in AppState, we might have to skip full integration test here 
    // and focus on the logic if we can't easily create AppState.
    
    // WAIT, `api/registry.rs` handlers take `State(AppState)`. 
    // If we can't create `AppState`, we can't test handlers easily with `oneshot`.
    
    // Alternative: Create a test that doesn't rely on `AppState` but on a `Registry` struct.
    // But the code uses `AppState`.
    
    // Let's look at `AppState` definition again.
    // pub struct AppState { config, nats_client, persistence_client, registry }
    
    // If we can't construct NatsClient without a real NATS server, we are stuck.
    // We should probably refactor `registry` to be a separate struct that `AppState` holds,
    // and test that struct. 
    
    // Refactoring plan:
    // 1. Create `ServiceRegistry` struct wrapping the HashMap.
    // 2. Move logic (insert, get, remove) there.
    // 3. Test `ServiceRegistry` independently.
    // 4. Update `AppState` to use `ServiceRegistry`.
    
}

// Since I cannot easily run NATS in this environment for unit tests, 
// I will refactor the Registry logic into a standalone struct `ServiceRegistry` 
// which CAN be unit tested without NATS.

