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() {
let (llm_url, _h1) = spawn_mock_llm().await;
let (gw_url, _h2) = spawn_gateway(test_state(&test_config(&llm_url))).await;
let resp = reqwest::Client::new()
.post(format!("{gw_url}/v1/conversations"))
.json(&serde_json::json!({"store": false}))
.send()
.await
.unwrap();
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() {
let (llm_url, _h1) = spawn_mock_llm().await;
let (gw_url, _h2) = spawn_gateway(test_state(&test_config(&llm_url))).await;
let resp = reqwest::Client::new()
.post(format!("{gw_url}/v1/conversations"))
.header("Content-Type", "application/json")
.body("{}")
.send()
.await
.unwrap();
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() {
let (llm_url, _h1) = spawn_mock_llm().await;
let (gw_url, _h2) = spawn_gateway(test_state(&test_config(&llm_url))).await;
let resp = reqwest::Client::new()
.post(format!("{gw_url}/v1/conversations"))
.send()
.await
.unwrap();
assert!(
!resp.status().is_client_error(),
"expected executor path, got client error"
);
}