use anthropic_async::AnthropicConfig;
use anthropic_async::Client;
use anthropic_async::types::content::*;
use anthropic_async::types::messages::*;
use wiremock::Mock;
use wiremock::MockServer;
use wiremock::ResponseTemplate;
use wiremock::matchers::method;
use wiremock::matchers::path;

#[tokio::test]
async fn test_count_tokens() {
    let server = MockServer::start().await;

    Mock::given(method("POST"))
        .and(path("/v1/messages/count_tokens"))
        .respond_with(
            ResponseTemplate::new(200).set_body_json(serde_json::json!({ "input_tokens": 42 })),
        )
        .mount(&server)
        .await;

    let req = MessageTokensCountRequest {
        model: "claude-haiku-4-5".into(),
        system: None,
        messages: vec![MessageParam {
            role: MessageRole::User,
            content: "Count my tokens".into(),
        }],
        tools: None,
        tool_choice: None,
    };

    let cfg = AnthropicConfig::new()
        .with_api_key("test")
        .with_api_base(server.uri());
    let client = Client::with_config(cfg);

    let response = client.messages().count_tokens(req).await.unwrap();
    assert_eq!(response.input_tokens, 42);
}
