agentic-server 0.5.0

Standalone axum server for agentic-api
Documentation
mod common;

use http::StatusCode;

use common::{spawn_gateway, spawn_mock_llm, test_config, test_state};

#[tokio::test]
async fn test_conversations_store_false_returns_400() {
    // Arrange
    let (llm_url, _h1) = spawn_mock_llm().await;
    let (gw_url, _h2) = spawn_gateway(test_state(&test_config(&llm_url))).await;

    // Act
    let resp = reqwest::Client::new()
        .post(format!("{gw_url}/v1/conversations"))
        .json(&serde_json::json!({"store": false}))
        .send()
        .await
        .unwrap();

    // Assert
    assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
    let body: serde_json::Value = resp.json().await.unwrap();
    assert_eq!(body["error"]["code"], "invalid_request_error");
}

#[tokio::test]
async fn test_conversations_empty_body_defaults_store_true_reaches_executor() {
    // Arrange — disabled store, so executor will error (not a 4xx)
    let (llm_url, _h1) = spawn_mock_llm().await;
    let (gw_url, _h2) = spawn_gateway(test_state(&test_config(&llm_url))).await;

    // Act — empty JSON body; store defaults to true
    let resp = reqwest::Client::new()
        .post(format!("{gw_url}/v1/conversations"))
        .header("Content-Type", "application/json")
        .body("{}")
        .send()
        .await
        .unwrap();

    // Assert — reached executor path (storage disabled → 5xx, not a 4xx rejection)
    assert!(
        !resp.status().is_client_error(),
        "expected executor path, got client error"
    );
}

#[tokio::test]
async fn test_conversations_no_content_type_still_defaults_store_true() {
    // Arrange
    let (llm_url, _h1) = spawn_mock_llm().await;
    let (gw_url, _h2) = spawn_gateway(test_state(&test_config(&llm_url))).await;

    // Act — no body at all
    let resp = reqwest::Client::new()
        .post(format!("{gw_url}/v1/conversations"))
        .send()
        .await
        .unwrap();

    // Assert — reached executor path (not a 4xx rejection)
    assert!(
        !resp.status().is_client_error(),
        "expected executor path, got client error"
    );
}