//! HTTP-level smoke tests against a mock Ollama server (paths such as `/api/tags`).

use std::time::Duration;

use ollama_kit::{OllamaRuntime, RuntimeConfig, RuntimeMode};
use wiremock::{
    matchers::{method, path},
    Mock, MockServer, ResponseTemplate,
};

#[tokio::test]
async fn lists_local_models_against_wiremock() {
    let mock = MockServer::start().await;
    Mock::given(method("GET"))
        .and(path("/api/tags"))
        .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
            "models": []
        })))
        .mount(&mock)
        .await;

    let config = RuntimeConfig {
        base_url: mock.uri(),
        timeout: Duration::from_secs(2),
        connect_timeout: Duration::from_secs(2),
        max_retries: 0,
        max_concurrent: 2,
        auto_pull: false,
        mode: RuntimeMode::Production,
        auth: None,
    };

    let runtime = OllamaRuntime::new(config).await.expect("runtime");
    let models = runtime
        .client()
        .list_local_models()
        .await
        .expect("list models");
    assert!(models.is_empty());
}

#[tokio::test]
#[ignore = "requires a reachable Ollama server; set base_url accordingly"]
async fn ignored_live_ollama_placeholder() {
    let base_url =
        std::env::var("OLLAMA_BASE_URL").unwrap_or_else(|_| "http://127.0.0.1:11434".into());
    let config = RuntimeConfig {
        base_url,
        timeout: Duration::from_secs(30),
        connect_timeout: Duration::from_secs(5),
        max_retries: 0,
        max_concurrent: 1,
        auto_pull: false,
        mode: RuntimeMode::Production,
        auth: None,
    };
    let runtime = OllamaRuntime::new(config).await.expect("runtime");
    let _ = runtime
        .client()
        .list_local_models()
        .await
        .expect("live list");
}
