use std::collections::BTreeMap; use crank_core::{ ExecutionConfig, HttpMethod, Operation, OperationId, OperationSecurityLevel, OperationStatus, Protocol, RestTarget, Target, ToolDescription, }; use crank_mapping::MappingSet; use crank_runtime::RuntimeExecutor; use crank_schema::{Schema, SchemaKind}; use serde_json::json; use time::OffsetDateTime; #[test] fn prepares_empty_request_for_no_input_get_with_empty_mapping() { let executor = RuntimeExecutor::new(); let operation = no_input_get_operation(); let request = executor .prepare_request(&operation.into(), &json!({})) .unwrap(); assert!(request.path_params.is_empty()); assert!(request.query_params.is_empty()); assert!(request.headers.is_empty()); assert!(request.body.is_none()); } fn no_input_get_operation() -> Operation { Operation { id: OperationId::new("op_no_input_get"), name: "internal_health".to_owned(), display_name: "Internal Health".to_owned(), category: "smoke".to_owned(), protocol: Protocol::Rest, security_level: OperationSecurityLevel::Standard, status: OperationStatus::Draft, version: 1, target: Target::Rest(RestTarget { base_url: "http://admin-api:3001".to_owned(), method: HttpMethod::Get, path_template: "/health".to_owned(), static_headers: BTreeMap::new(), }), input_schema: Schema { kind: SchemaKind::Object, description: None, required: true, nullable: false, default_value: None, fields: BTreeMap::new(), items: None, enum_values: Vec::new(), variants: Vec::new(), }, output_schema: Schema { kind: SchemaKind::Object, description: None, required: true, nullable: false, default_value: None, fields: BTreeMap::new(), items: None, enum_values: Vec::new(), variants: Vec::new(), }, input_mapping: MappingSet { rules: Vec::new() }, output_mapping: MappingSet { rules: Vec::new() }, execution_config: ExecutionConfig { timeout_ms: 1_000, retry_policy: None, response_cache: None, idempotency: None, safety: None, auth_profile_ref: None, headers: BTreeMap::new(), }, tool_description: ToolDescription { title: "Internal Health".to_owned(), description: "Checks internal health.".to_owned(), tags: Vec::new(), examples: Vec::new(), }, samples: None, generated_draft: None, config_export: None, wizard_state: None, created_at: OffsetDateTime::UNIX_EPOCH, updated_at: OffsetDateTime::UNIX_EPOCH, published_at: None, } }