use crate::providers::openai_shared::OpenAIJsonSchema;
use crate::provider::Response;
use crate::provider::ResponseFormat;
use serde_json::json;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_empty_structured_response() {
let response = Response {
content: "Simple text response".to_string(),
structured_response: None,
tool_calls: vec![],
usage: None,
model: Some("test-model".to_string()),
raw_body: None,
};
assert!(response.structured_response.is_none());
assert_eq!(response.content, "Simple text response");
}
#[test]
fn test_structured_response_with_empty_schema() {
let response = Response {
content: "{}".to_string(),
structured_response: Some(json!({})),
tool_calls: vec![],
usage: None,
model: Some("test-model".to_string()),
raw_body: None,
};
assert!(response.structured_response.is_some());
assert_eq!(response.structured_response.unwrap(), json!({}));
}
#[test]
fn test_response_format_with_empty_name() {
let format = ResponseFormat {
name: String::new(),
schema: json!({"type": "object"}),
};
assert!(format.name.is_empty());
assert_eq!(format.schema["type"], "object");
}
#[test]
fn test_openai_json_schema_strict_mode_variations() {
let schema_strict_true = OpenAIJsonSchema {
name: "test".to_string(),
schema: json!({"type": "object"}),
strict: Some(true),
};
let schema_strict_false = OpenAIJsonSchema {
name: "test".to_string(),
schema: json!({"type": "object"}),
strict: Some(false),
};
let schema_no_strict = OpenAIJsonSchema {
name: "test".to_string(),
schema: json!({"type": "object"}),
strict: None,
};
assert_eq!(schema_strict_true.strict, Some(true));
assert_eq!(schema_strict_false.strict, Some(false));
assert_eq!(schema_no_strict.strict, None);
}
}