diff --git a/src/bot/mod.rs b/src/bot/mod.rs index 40edb6f..e478362 100644 --- a/src/bot/mod.rs +++ b/src/bot/mod.rs @@ -46,7 +46,7 @@ pub struct AssertionResult { } impl AssertionResult { - #[must_use] + #[must_use] pub fn pass(message: &str) -> Self { Self { passed: true, @@ -56,7 +56,7 @@ impl AssertionResult { } } - #[must_use] + #[must_use] pub fn fail(message: &str, expected: &str, actual: &str) -> Self { Self { passed: false, diff --git a/src/desktop/mod.rs b/src/desktop/mod.rs index 2d419bf..c2ffe07 100644 --- a/src/desktop/mod.rs +++ b/src/desktop/mod.rs @@ -38,13 +38,13 @@ impl DesktopConfig { } } - #[must_use] + #[must_use] pub fn with_args(mut self, args: Vec) -> Self { self.args = args; self } - #[must_use] + #[must_use] pub fn with_env(mut self, key: &str, value: &str) -> Self { self.env_vars.insert(key.to_string(), value.to_string()); self @@ -55,7 +55,7 @@ impl DesktopConfig { self } - #[must_use] + #[must_use] pub const fn with_timeout(mut self, timeout: Duration) -> Self { self.timeout = timeout; self @@ -70,7 +70,7 @@ pub enum Platform { } impl Platform { - #[must_use] + #[must_use] pub const fn current() -> Self { #[cfg(target_os = "windows")] return Platform::Windows; @@ -91,7 +91,7 @@ pub struct DesktopApp { } impl DesktopApp { - #[must_use] + #[must_use] pub const fn new(config: DesktopConfig) -> Self { Self { config, @@ -161,12 +161,12 @@ impl DesktopApp { } } - #[must_use] + #[must_use] pub const fn pid(&self) -> Option { self.pid } - #[must_use] + #[must_use] pub const fn platform(&self) -> Platform { self.platform } @@ -269,22 +269,22 @@ pub enum ElementLocator { } impl ElementLocator { - #[must_use] + #[must_use] pub fn accessibility_id(id: &str) -> Self { Self::AccessibilityId(id.to_string()) } - #[must_use] + #[must_use] pub fn name(name: &str) -> Self { Self::Name(name.to_string()) } - #[must_use] + #[must_use] pub fn role(role: &str) -> Self { Self::Role(role.to_string()) } - #[must_use] + #[must_use] pub fn path(path: &str) -> Self { Self::Path(path.to_string()) } @@ -322,12 +322,12 @@ impl Element { anyhow::bail!("Element clear not yet implemented") } - #[must_use] + #[must_use] pub fn text(&self) -> Option<&str> { self.value.as_deref() } - #[must_use] + #[must_use] pub const fn is_displayed(&self) -> bool { self.bounds.width > 0 && self.bounds.height > 0 } diff --git a/src/fixtures/data/mod.rs b/src/fixtures/data/mod.rs index 6e69045..7b42a26 100644 --- a/src/fixtures/data/mod.rs +++ b/src/fixtures/data/mod.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; use std::collections::HashMap; -#[must_use] +#[must_use] pub fn sample_config() -> HashMap { let mut config = HashMap::new(); config.insert("llm-model".to_string(), "gpt-4".to_string()); @@ -16,7 +16,7 @@ pub fn sample_config() -> HashMap { config } -#[must_use] +#[must_use] pub fn sample_bot_config() -> Value { json!({ "name": "test-bot", @@ -49,7 +49,7 @@ pub fn sample_bot_config() -> Value { }) } -#[must_use] +#[must_use] pub fn whatsapp_text_message(from: &str, text: &str) -> Value { json!({ "object": "whatsapp_business_account", @@ -84,7 +84,7 @@ pub fn whatsapp_text_message(from: &str, text: &str) -> Value { }) } -#[must_use] +#[must_use] pub fn whatsapp_button_reply(from: &str, button_id: &str, button_text: &str) -> Value { json!({ "object": "whatsapp_business_account", @@ -123,7 +123,7 @@ pub fn whatsapp_button_reply(from: &str, button_id: &str, button_text: &str) -> }) } -#[must_use] +#[must_use] pub fn teams_message_activity(from_id: &str, from_name: &str, text: &str) -> Value { json!({ "type": "message", @@ -156,7 +156,7 @@ pub fn teams_message_activity(from_id: &str, from_name: &str, text: &str) -> Val }) } -#[must_use] +#[must_use] pub fn openai_chat_request(messages: Vec<(&str, &str)>) -> Value { let msgs: Vec = messages .into_iter() @@ -176,7 +176,7 @@ pub fn openai_chat_request(messages: Vec<(&str, &str)>) -> Value { }) } -#[must_use] +#[must_use] pub fn openai_chat_response(content: &str) -> Value { json!({ "id": format!("chatcmpl-{}", uuid::Uuid::new_v4()), @@ -199,7 +199,7 @@ pub fn openai_chat_response(content: &str) -> Value { }) } -#[must_use] +#[must_use] pub fn openai_embedding_response(dimensions: usize) -> Value { let embedding: Vec = (0..dimensions) .map(|i| (i as f64) / (dimensions as f64)) @@ -220,7 +220,7 @@ pub fn openai_embedding_response(dimensions: usize) -> Value { }) } -#[must_use] +#[must_use] pub fn sample_kb_entries() -> Vec { vec![ KBEntry { @@ -263,7 +263,7 @@ pub struct KBEntry { pub tags: Vec, } -#[must_use] +#[must_use] pub fn sample_products() -> Vec { vec![ Product { @@ -303,7 +303,7 @@ pub struct Product { pub category: String, } -#[must_use] +#[must_use] pub fn sample_faqs() -> Vec { vec![ FAQ { @@ -344,7 +344,7 @@ pub struct FAQ { pub mod errors { use serde_json::{json, Value}; - #[must_use] + #[must_use] pub fn validation_error(field: &str, message: &str) -> Value { json!({ "error": { @@ -358,7 +358,7 @@ pub mod errors { }) } - #[must_use] + #[must_use] pub fn not_found(resource: &str, id: &str) -> Value { json!({ "error": { @@ -368,7 +368,7 @@ pub mod errors { }) } - #[must_use] + #[must_use] pub fn unauthorized() -> Value { json!({ "error": { @@ -378,7 +378,7 @@ pub mod errors { }) } - #[must_use] + #[must_use] pub fn forbidden() -> Value { json!({ "error": { @@ -388,7 +388,7 @@ pub mod errors { }) } - #[must_use] + #[must_use] pub fn rate_limited(retry_after: u32) -> Value { json!({ "error": { @@ -399,7 +399,7 @@ pub mod errors { }) } - #[must_use] + #[must_use] pub fn internal_error() -> Value { json!({ "error": { diff --git a/src/fixtures/mod.rs b/src/fixtures/mod.rs index 91d1ee6..f4d6b0e 100644 --- a/src/fixtures/mod.rs +++ b/src/fixtures/mod.rs @@ -279,7 +279,7 @@ impl Default for QueueStatus { } -#[must_use] +#[must_use] pub fn admin_user() -> User { User { email: "admin@test.com".to_string(), @@ -289,7 +289,7 @@ pub fn admin_user() -> User { } } -#[must_use] +#[must_use] pub fn attendant_user() -> User { User { email: "attendant@test.com".to_string(), @@ -299,7 +299,7 @@ pub fn attendant_user() -> User { } } -#[must_use] +#[must_use] pub fn regular_user() -> User { User { email: "user@test.com".to_string(), @@ -309,7 +309,7 @@ pub fn regular_user() -> User { } } -#[must_use] +#[must_use] pub fn user_with_email(email: &str) -> User { User { email: email.to_string(), @@ -318,7 +318,7 @@ pub fn user_with_email(email: &str) -> User { } } -#[must_use] +#[must_use] pub fn customer(phone: &str) -> Customer { Customer { phone: Some(phone.to_string()), @@ -327,7 +327,7 @@ pub fn customer(phone: &str) -> Customer { } } -#[must_use] +#[must_use] pub fn customer_on_channel(channel: Channel) -> Customer { Customer { channel, @@ -335,7 +335,7 @@ pub fn customer_on_channel(channel: Channel) -> Customer { } } -#[must_use] +#[must_use] pub fn teams_customer() -> Customer { Customer { channel: Channel::Teams, @@ -344,7 +344,7 @@ pub fn teams_customer() -> Customer { } } -#[must_use] +#[must_use] pub fn web_customer() -> Customer { Customer { channel: Channel::Web, @@ -353,7 +353,7 @@ pub fn web_customer() -> Customer { } } -#[must_use] +#[must_use] pub fn basic_bot(name: &str) -> Bot { Bot { name: name.to_string(), @@ -363,7 +363,7 @@ pub fn basic_bot(name: &str) -> Bot { } } -#[must_use] +#[must_use] pub fn bot_with_kb(name: &str) -> Bot { Bot { name: name.to_string(), @@ -373,7 +373,7 @@ pub fn bot_with_kb(name: &str) -> Bot { } } -#[must_use] +#[must_use] pub fn rule_based_bot(name: &str) -> Bot { Bot { name: name.to_string(), @@ -384,7 +384,7 @@ pub fn rule_based_bot(name: &str) -> Bot { } } -#[must_use] +#[must_use] pub fn session_for(bot: &Bot, customer: &Customer) -> Session { Session { bot_id: bot.id, @@ -394,7 +394,7 @@ pub fn session_for(bot: &Bot, customer: &Customer) -> Session { } } -#[must_use] +#[must_use] pub fn active_session() -> Session { Session { state: SessionState::Active, @@ -402,7 +402,7 @@ pub fn active_session() -> Session { } } -#[must_use] +#[must_use] pub fn incoming_message(content: &str) -> Message { Message { direction: MessageDirection::Incoming, @@ -411,7 +411,7 @@ pub fn incoming_message(content: &str) -> Message { } } -#[must_use] +#[must_use] pub fn outgoing_message(content: &str) -> Message { Message { direction: MessageDirection::Outgoing, @@ -420,7 +420,7 @@ pub fn outgoing_message(content: &str) -> Message { } } -#[must_use] +#[must_use] pub fn message_in_session( session: &Session, content: &str, @@ -434,7 +434,7 @@ pub fn message_in_session( } } -#[must_use] +#[must_use] pub fn queue_entry_for(customer: &Customer, session: &Session) -> QueueEntry { QueueEntry { customer_id: customer.id, @@ -443,7 +443,7 @@ pub fn queue_entry_for(customer: &Customer, session: &Session) -> QueueEntry { } } -#[must_use] +#[must_use] pub fn high_priority_queue_entry() -> QueueEntry { QueueEntry { priority: Priority::High, @@ -451,7 +451,7 @@ pub fn high_priority_queue_entry() -> QueueEntry { } } -#[must_use] +#[must_use] pub fn urgent_queue_entry() -> QueueEntry { QueueEntry { priority: Priority::Urgent, diff --git a/src/fixtures/scripts/mod.rs b/src/fixtures/scripts/mod.rs index e0bf3f2..b2366c1 100644 --- a/src/fixtures/scripts/mod.rs +++ b/src/fixtures/scripts/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; -#[must_use] +#[must_use] pub fn get_script(name: &str) -> Option<&'static str> { match name { "greeting" => Some(GREETING_SCRIPT), @@ -18,7 +18,7 @@ pub fn get_script(name: &str) -> Option<&'static str> { } } -#[must_use] +#[must_use] pub fn available_scripts() -> Vec<&'static str> { vec![ "greeting", @@ -34,7 +34,7 @@ pub fn available_scripts() -> Vec<&'static str> { ] } -#[must_use] +#[must_use] pub fn all_scripts() -> HashMap<&'static str, &'static str> { let mut scripts = HashMap::new(); for name in available_scripts() { diff --git a/src/harness.rs b/src/harness.rs index 88605ee..2568a15 100644 --- a/src/harness.rs +++ b/src/harness.rs @@ -35,7 +35,7 @@ impl Default for TestConfig { } impl TestConfig { - #[must_use] + #[must_use] pub const fn minimal() -> Self { Self { postgres: false, @@ -47,31 +47,31 @@ impl TestConfig { } } - #[must_use] + #[must_use] pub const fn full() -> Self { Self { - postgres: false, // Botserver will bootstrap its own PostgreSQL - minio: false, // Botserver will bootstrap its own MinIO - redis: false, // Botserver will bootstrap its own Redis + postgres: false, + minio: false, + redis: false, mock_zitadel: true, mock_llm: true, - run_migrations: false, // Let botserver run its own migrations + run_migrations: false, } } - #[must_use] + #[must_use] pub const fn auto_install() -> Self { Self { - postgres: false, // Botserver will install PostgreSQL - minio: false, // Botserver will install MinIO - redis: false, // Botserver will install Redis + postgres: false, + minio: false, + redis: false, mock_zitadel: true, mock_llm: true, - run_migrations: false, // Botserver handles migrations + run_migrations: false, } } - #[must_use] + #[must_use] pub const fn database_only() -> Self { Self { postgres: true, @@ -80,7 +80,7 @@ impl TestConfig { } } - #[must_use] + #[must_use] pub const fn use_existing_stack() -> Self { Self { postgres: false, @@ -450,7 +450,7 @@ pub struct BotServerInstance { } impl BotServerInstance { - #[must_use] + #[must_use] pub fn existing(url: &str) -> Self { let port = url .split(':') @@ -482,9 +482,9 @@ impl BotServerInstance { let botserver_bin_path = std::fs::canonicalize(&botserver_bin).unwrap_or_else(|_| PathBuf::from(&botserver_bin)); let botserver_dir = botserver_bin_path - .parent() // target/debug - .and_then(|p| p.parent()) // target - .and_then(|p| p.parent()) // botserver + .parent() + .and_then(|p| p.parent()) + .and_then(|p| p.parent()) .map(std::path::Path::to_path_buf) .unwrap_or_else(|| { std::fs::canonicalize("../botserver") @@ -514,7 +514,7 @@ impl BotServerInstance { .ok(); if process.is_some() { - let max_wait = 120; // 2 minutes for LLM + let max_wait = 120; log::info!("Waiting for botserver to start (max {max_wait}s)..."); let client = reqwest::Client::builder() @@ -562,7 +562,7 @@ pub struct BotUIInstance { } impl BotUIInstance { - #[must_use] + #[must_use] pub fn existing(url: &str) -> Self { let port = url .split(':') @@ -597,9 +597,9 @@ impl BotUIInstance { let botui_bin_path = std::fs::canonicalize(&botui_bin).unwrap_or_else(|_| PathBuf::from(&botui_bin)); let botui_dir = botui_bin_path - .parent() // target/debug - .and_then(|p| p.parent()) // target - .and_then(|p| p.parent()) // botui + .parent() + .and_then(|p| p.parent()) + .and_then(|p| p.parent()) .map(std::path::Path::to_path_buf) .unwrap_or_else(|| { std::fs::canonicalize("../botui").unwrap_or_else(|_| PathBuf::from("../botui")) @@ -651,7 +651,7 @@ impl BotUIInstance { }) } - #[must_use] + #[must_use] pub const fn is_running(&self) -> bool { self.process.is_some() } @@ -694,9 +694,9 @@ impl BotServerInstance { let botserver_bin_path = std::fs::canonicalize(&botserver_bin).unwrap_or_else(|_| PathBuf::from(&botserver_bin)); let botserver_dir = botserver_bin_path - .parent() // target/release - .and_then(|p| p.parent()) // target - .and_then(|p| p.parent()) // botserver + .parent() + .and_then(|p| p.parent()) + .and_then(|p| p.parent()) .map(std::path::Path::to_path_buf) .unwrap_or_else(|| { std::fs::canonicalize("../botserver") @@ -712,13 +712,13 @@ impl BotServerInstance { log::info!("Using installers from: {installers_path:?}"); let process = std::process::Command::new(&botserver_bin_path) - .current_dir(&botserver_dir) // Run from botserver dir to find installers + .current_dir(&botserver_dir) .arg("--stack-path") .arg(&stack_path) .arg("--port") .arg(port.to_string()) .arg("--noconsole") - .env_remove("RUST_LOG") // Remove to avoid logger conflict + .env_remove("RUST_LOG") .env("BOTSERVER_INSTALLERS_PATH", &installers_path) .env("DATABASE_URL", ctx.database_url()) .env("DIRECTORY_URL", ctx.zitadel_url()) @@ -764,7 +764,7 @@ impl BotServerInstance { }) } - #[must_use] + #[must_use] pub const fn is_running(&self) -> bool { self.process.is_some() } @@ -1032,12 +1032,12 @@ mod tests { #[test] fn test_config_full() { let config = TestConfig::full(); - assert!(!config.postgres); // Botserver handles PostgreSQL - assert!(!config.minio); // Botserver handles MinIO - assert!(!config.redis); // Botserver handles Redis + assert!(!config.postgres); + assert!(!config.minio); + assert!(!config.redis); assert!(config.mock_zitadel); assert!(config.mock_llm); - assert!(!config.run_migrations); // Botserver handles migrations + assert!(!config.run_migrations); } #[test] diff --git a/src/main.rs b/src/main.rs index 726c07b..d33db43 100644 --- a/src/main.rs +++ b/src/main.rs @@ -193,7 +193,7 @@ pub struct TestResults { } impl TestResults { - #[must_use] + #[must_use] pub fn new(suite: &str) -> Self { Self { suite: suite.to_string(), @@ -205,7 +205,7 @@ impl TestResults { } } - #[must_use] + #[must_use] pub const fn success(&self) -> bool { self.failed == 0 && self.errors.is_empty() } diff --git a/src/mocks/llm.rs b/src/mocks/llm.rs index de31d68..2b8b28c 100644 --- a/src/mocks/llm.rs +++ b/src/mocks/llm.rs @@ -563,12 +563,12 @@ impl MockLLM { .await; } - #[must_use] + #[must_use] pub fn url(&self) -> String { format!("http://127.0.0.1:{}", self.port) } - #[must_use] + #[must_use] pub const fn port(&self) -> u16 { self.port } diff --git a/src/mocks/mod.rs b/src/mocks/mod.rs index 87cf203..dd8fe3f 100644 --- a/src/mocks/mod.rs +++ b/src/mocks/mod.rs @@ -21,7 +21,7 @@ pub struct MockRegistry { } impl MockRegistry { - #[must_use] + #[must_use] pub const fn new() -> Self { Self { llm: None, @@ -31,22 +31,22 @@ impl MockRegistry { } } - #[must_use] + #[must_use] pub const fn llm(&self) -> &MockLLM { self.llm.as_ref().expect("LLM mock not configured") } - #[must_use] + #[must_use] pub const fn whatsapp(&self) -> &MockWhatsApp { self.whatsapp.as_ref().expect("WhatsApp mock not configured") } - #[must_use] + #[must_use] pub const fn teams(&self) -> &MockTeams { self.teams.as_ref().expect("Teams mock not configured") } - #[must_use] + #[must_use] pub const fn zitadel(&self) -> &MockZitadel { self.zitadel.as_ref().expect("Zitadel mock not configured") } @@ -98,7 +98,7 @@ pub struct Expectation { } impl Expectation { - #[must_use] + #[must_use] pub fn new(name: &str) -> Self { Self { name: name.to_string(), @@ -108,7 +108,7 @@ impl Expectation { } } - #[must_use] + #[must_use] pub const fn times(mut self, n: usize) -> Self { self.expected_calls = Some(n); self @@ -136,7 +136,7 @@ impl Expectation { pub type ExpectationStore = Arc>>; -#[must_use] +#[must_use] pub fn new_expectation_store() -> ExpectationStore { Arc::new(Mutex::new(HashMap::new())) } diff --git a/src/mocks/teams.rs b/src/mocks/teams.rs index 45ff0c0..681b525 100644 --- a/src/mocks/teams.rs +++ b/src/mocks/teams.rs @@ -429,7 +429,7 @@ impl MockTeams { .await; } - #[must_use] + #[must_use] pub fn simulate_message(&self, from_id: &str, from_name: &str, text: &str) -> Activity { let conversation_id = format!("conv-{}", Uuid::new_v4()); @@ -476,7 +476,7 @@ impl MockTeams { } } - #[must_use] + #[must_use] pub fn simulate_mention(&self, from_id: &str, from_name: &str, text: &str) -> Activity { let mut activity = self.simulate_message(from_id, from_name, text); @@ -498,7 +498,7 @@ impl MockTeams { activity } - #[must_use] + #[must_use] pub fn simulate_member_added(&self, member_id: &str, member_name: &str) -> Activity { let conversation_id = format!("conv-{}", Uuid::new_v4()); @@ -546,7 +546,7 @@ impl MockTeams { } } - #[must_use] + #[must_use] pub fn simulate_invoke( &self, from_id: &str, @@ -599,7 +599,7 @@ impl MockTeams { } } - #[must_use] + #[must_use] pub fn simulate_adaptive_card_action( &self, from_id: &str, @@ -620,7 +620,7 @@ impl MockTeams { ) } - #[must_use] + #[must_use] pub fn simulate_reaction( &self, from_id: &str, @@ -698,12 +698,12 @@ impl MockTeams { .await; } - #[must_use] + #[must_use] pub fn sent_activities(&self) -> Vec { self.sent_activities.lock().unwrap().clone() } - #[must_use] + #[must_use] pub fn sent_activities_containing(&self, text: &str) -> Vec { self.sent_activities .lock() @@ -714,7 +714,7 @@ impl MockTeams { .collect() } - #[must_use] + #[must_use] pub fn last_sent_activity(&self) -> Option { self.sent_activities.lock().unwrap().last().cloned() } @@ -730,32 +730,32 @@ impl MockTeams { .insert(info.id.clone(), info); } - #[must_use] + #[must_use] pub fn url(&self) -> String { format!("http://127.0.0.1:{}", self.port) } - #[must_use] + #[must_use] pub fn service_url(&self) -> String { self.service_url.clone() } - #[must_use] + #[must_use] pub const fn port(&self) -> u16 { self.port } - #[must_use] + #[must_use] pub fn bot_id(&self) -> &str { &self.bot_id } - #[must_use] + #[must_use] pub fn bot_name(&self) -> &str { &self.bot_name } - #[must_use] + #[must_use] pub fn tenant_id(&self) -> &str { &self.tenant_id } diff --git a/src/mocks/whatsapp.rs b/src/mocks/whatsapp.rs index 97f82e4..42ee509 100644 --- a/src/mocks/whatsapp.rs +++ b/src/mocks/whatsapp.rs @@ -481,7 +481,7 @@ impl MockWhatsApp { .await; } - #[must_use] + #[must_use] pub fn expect_send_message(&self, to: &str) -> MessageExpectation { MessageExpectation { to: to.to_string(), @@ -490,7 +490,7 @@ impl MockWhatsApp { } } - #[must_use] + #[must_use] pub fn expect_send_template(&self, name: &str) -> TemplateExpectation { TemplateExpectation { name: name.to_string(), @@ -759,12 +759,12 @@ impl MockWhatsApp { .await; } - #[must_use] + #[must_use] pub fn sent_messages(&self) -> Vec { self.sent_messages.lock().unwrap().clone() } - #[must_use] + #[must_use] pub fn sent_messages_to(&self, phone: &str) -> Vec { self.sent_messages .lock() @@ -775,7 +775,7 @@ impl MockWhatsApp { .collect() } - #[must_use] + #[must_use] pub fn last_sent_message(&self) -> Option { self.sent_messages.lock().unwrap().last().cloned() } @@ -784,32 +784,32 @@ impl MockWhatsApp { self.sent_messages.lock().unwrap().clear(); } - #[must_use] + #[must_use] pub fn url(&self) -> String { format!("http://127.0.0.1:{}", self.port) } - #[must_use] + #[must_use] pub fn graph_api_url(&self) -> String { format!("http://127.0.0.1:{}/v17.0", self.port) } - #[must_use] + #[must_use] pub const fn port(&self) -> u16 { self.port } - #[must_use] + #[must_use] pub fn phone_number_id(&self) -> &str { &self.phone_number_id } - #[must_use] + #[must_use] pub fn business_account_id(&self) -> &str { &self.business_account_id } - #[must_use] + #[must_use] pub fn access_token(&self) -> &str { &self.access_token } diff --git a/src/mocks/zitadel.rs b/src/mocks/zitadel.rs index 251cddd..b97fb72 100644 --- a/src/mocks/zitadel.rs +++ b/src/mocks/zitadel.rs @@ -215,7 +215,7 @@ impl MockZitadel { .await; } - #[must_use] + #[must_use] pub fn create_test_user(&self, email: &str) -> TestUser { let user = TestUser { id: Uuid::new_v4().to_string(), @@ -232,7 +232,7 @@ impl MockZitadel { user } - #[must_use] + #[must_use] pub fn create_user(&self, user: TestUser) -> TestUser { self.users .lock() @@ -487,7 +487,7 @@ impl MockZitadel { format!("{header}.{payload}.{signature}") } - #[must_use] + #[must_use] pub fn generate_token(&self, user: &TestUser) -> String { let access_token = format!("test_access_{}", Uuid::new_v4()); let now = SystemTime::now() @@ -520,22 +520,22 @@ impl MockZitadel { } } - #[must_use] + #[must_use] pub fn url(&self) -> String { format!("http://127.0.0.1:{}", self.port) } - #[must_use] + #[must_use] pub fn issuer(&self) -> String { self.issuer.clone() } - #[must_use] + #[must_use] pub const fn port(&self) -> u16 { self.port } - #[must_use] + #[must_use] pub fn discovery_url(&self) -> String { format!("{}/.well-known/openid-configuration", self.url()) } @@ -652,7 +652,7 @@ mod tests { assert!(json.contains("access_token")); assert!(json.contains("Bearer")); assert!(json.contains("refresh_token")); - assert!(!json.contains("id_token")); // Should be skipped when None + assert!(!json.contains("id_token")); } #[test] diff --git a/src/ports.rs b/src/ports.rs index 576f9f6..52e8681 100644 --- a/src/ports.rs +++ b/src/ports.rs @@ -26,7 +26,7 @@ impl PortAllocator { } } - #[must_use] + #[must_use] pub fn allocate_range(count: usize) -> Vec { (0..count).map(|_| Self::allocate()).collect() } diff --git a/src/services/browser_service.rs b/src/services/browser_service.rs index d4e5ad8..180c6e5 100644 --- a/src/services/browser_service.rs +++ b/src/services/browser_service.rs @@ -154,17 +154,17 @@ impl BrowserService { anyhow::bail!("No supported browser found. Install Brave, Chrome, or Chromium.") } - #[must_use] + #[must_use] pub fn ws_url(&self) -> String { format!("ws://127.0.0.1:{}", self.port) } - #[must_use] + #[must_use] pub fn http_url(&self) -> String { format!("http://127.0.0.1:{}", self.port) } - #[must_use] + #[must_use] pub const fn port(&self) -> u16 { self.port } diff --git a/src/services/minio.rs b/src/services/minio.rs index 3fa21ad..1dcb184 100644 --- a/src/services/minio.rs +++ b/src/services/minio.rs @@ -343,32 +343,32 @@ impl MinioService { Ok(()) } - #[must_use] + #[must_use] pub fn endpoint(&self) -> String { format!("http://127.0.0.1:{}", self.api_port) } - #[must_use] + #[must_use] pub fn console_url(&self) -> String { format!("http://127.0.0.1:{}", self.console_port) } - #[must_use] + #[must_use] pub const fn api_port(&self) -> u16 { self.api_port } - #[must_use] + #[must_use] pub const fn console_port(&self) -> u16 { self.console_port } - #[must_use] + #[must_use] pub fn credentials(&self) -> (String, String) { (self.access_key.clone(), self.secret_key.clone()) } - #[must_use] + #[must_use] pub fn s3_config(&self) -> HashMap { let mut config = HashMap::new(); config.insert("endpoint_url".to_string(), self.endpoint()); diff --git a/src/services/postgres.rs b/src/services/postgres.rs index a8608b4..6b8bdee 100644 --- a/src/services/postgres.rs +++ b/src/services/postgres.rs @@ -386,8 +386,8 @@ unix_socket_directories = '{}' &self.username, "-d", &self.database_name, - "-t", // tuples only - "-A", // unaligned + "-t", + "-A", "-c", sql, ]) @@ -401,12 +401,12 @@ unix_socket_directories = '{}' Ok(String::from_utf8_lossy(&output.stdout).trim().to_string()) } - #[must_use] + #[must_use] pub fn connection_string(&self) -> String { self.connection_string.clone() } - #[must_use] + #[must_use] pub const fn port(&self) -> u16 { self.port } diff --git a/src/services/redis.rs b/src/services/redis.rs index f5c3f05..150a60b 100644 --- a/src/services/redis.rs +++ b/src/services/redis.rs @@ -287,7 +287,7 @@ impl RedisService { Ok(val) } - #[must_use] + #[must_use] pub fn connection_string(&self) -> String { match &self.password { Some(pw) => format!("redis://:{}@127.0.0.1:{}", pw, self.port), @@ -295,17 +295,17 @@ impl RedisService { } } - #[must_use] + #[must_use] pub fn url(&self) -> String { self.connection_string() } - #[must_use] + #[must_use] pub const fn port(&self) -> u16 { self.port } - #[must_use] + #[must_use] pub const fn host_port(&self) -> (&str, u16) { ("127.0.0.1", self.port) } diff --git a/src/web/browser.rs b/src/web/browser.rs index 3e82f4a..906eab4 100644 --- a/src/web/browser.rs +++ b/src/web/browser.rs @@ -30,7 +30,7 @@ impl Default for BrowserType { } impl BrowserType { - #[must_use] + #[must_use] pub const fn browser_name(&self) -> &'static str { match self { Self::Chrome => "chrome", @@ -40,7 +40,7 @@ impl BrowserType { } } - #[must_use] + #[must_use] pub const fn capability_name(&self) -> &'static str { match self { Self::Chrome => "goog:chromeOptions", @@ -130,24 +130,24 @@ impl BrowserConfig { None } - #[must_use] + #[must_use] pub fn new() -> Self { Self::default() } - #[must_use] + #[must_use] pub const fn with_browser(mut self, browser: BrowserType) -> Self { self.browser_type = browser; self } - #[must_use] + #[must_use] pub const fn with_debug_port(mut self, port: u16) -> Self { self.debug_port = port; self } - #[must_use] + #[must_use] pub fn with_webdriver_url(mut self, url: &str) -> Self { if let Some(port_str) = url.split(':').next_back() { if let Ok(port) = port_str.parse() { @@ -157,31 +157,31 @@ impl BrowserConfig { self } - #[must_use] + #[must_use] pub const fn headless(mut self, headless: bool) -> Self { self.headless = headless; self } - #[must_use] + #[must_use] pub const fn with_window_size(mut self, width: u32, height: u32) -> Self { self.window_width = width; self.window_height = height; self } - #[must_use] + #[must_use] pub const fn with_timeout(mut self, timeout: Duration) -> Self { self.timeout = timeout; self } - #[must_use] + #[must_use] pub const fn with_arg(self, _arg: &str) -> Self { self } - #[must_use] + #[must_use] pub fn with_binary(mut self, path: &str) -> Self { self.binary_path = Some(path.to_string()); self @@ -213,7 +213,7 @@ impl BrowserConfig { .map_err(|e| anyhow::anyhow!("Failed to build CDP browser config: {e}")) } - #[must_use] + #[must_use] pub fn build_capabilities(&self) -> serde_json::Value { serde_json::json!({ "browserName": self.browser_type.browser_name(), @@ -897,10 +897,10 @@ impl Element { } pub async fn size(&self) -> Result<(u64, u64)> { - Ok((100, 20)) // Default size + Ok((100, 20)) } - #[must_use] + #[must_use] pub const fn locator(&self) -> &Locator { &self.locator } diff --git a/src/web/mod.rs b/src/web/mod.rs index dec0831..ba326ef 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -35,7 +35,7 @@ impl Default for E2EConfig { } impl E2EConfig { - #[must_use] + #[must_use] pub fn to_browser_config(&self) -> BrowserConfig { BrowserConfig::default() .with_browser(self.browser) @@ -77,37 +77,37 @@ pub enum Locator { } impl Locator { - #[must_use] + #[must_use] pub fn css(selector: &str) -> Self { Self::Css(selector.to_string()) } - #[must_use] + #[must_use] pub fn xpath(expr: &str) -> Self { Self::XPath(expr.to_string()) } - #[must_use] + #[must_use] pub fn id(id: &str) -> Self { Self::Id(id.to_string()) } - #[must_use] + #[must_use] pub fn name(name: &str) -> Self { Self::Name(name.to_string()) } - #[must_use] + #[must_use] pub fn link_text(text: &str) -> Self { Self::LinkText(text.to_string()) } - #[must_use] + #[must_use] pub fn class(name: &str) -> Self { Self::ClassName(name.to_string()) } - - #[must_use] + + #[must_use] pub fn to_css_selector(&self) -> String { match self { Self::Css(s) => s.clone(), @@ -198,86 +198,86 @@ pub enum Action { } impl ActionChain { - #[must_use] + #[must_use] pub const fn new() -> Self { Self { actions: Vec::new(), } } - #[must_use] + #[must_use] pub fn click(mut self, locator: Locator) -> Self { self.actions.push(Action::Click(locator)); self } - #[must_use] + #[must_use] pub fn double_click(mut self, locator: Locator) -> Self { self.actions.push(Action::DoubleClick(locator)); self } - #[must_use] + #[must_use] pub fn right_click(mut self, locator: Locator) -> Self { self.actions.push(Action::RightClick(locator)); self } - #[must_use] + #[must_use] pub fn move_to(mut self, locator: Locator) -> Self { self.actions.push(Action::MoveTo(locator)); self } - #[must_use] + #[must_use] pub fn move_by(mut self, x: i32, y: i32) -> Self { self.actions.push(Action::MoveByOffset(x, y)); self } - #[must_use] + #[must_use] pub fn key_down(mut self, key: Key) -> Self { self.actions.push(Action::KeyDown(key)); self } - #[must_use] + #[must_use] pub fn key_up(mut self, key: Key) -> Self { self.actions.push(Action::KeyUp(key)); self } - #[must_use] + #[must_use] pub fn send_keys(mut self, text: &str) -> Self { self.actions.push(Action::SendKeys(text.to_string())); self } - #[must_use] + #[must_use] pub fn pause(mut self, duration: Duration) -> Self { self.actions.push(Action::Pause(duration)); self } - #[must_use] + #[must_use] pub fn drag_and_drop(mut self, source: Locator, target: Locator) -> Self { self.actions.push(Action::DragAndDrop(source, target)); self } - #[must_use] + #[must_use] pub fn scroll_to(mut self, locator: Locator) -> Self { self.actions.push(Action::ScrollTo(locator)); self } - #[must_use] + #[must_use] pub fn scroll_by(mut self, x: i32, y: i32) -> Self { self.actions.push(Action::ScrollByAmount(x, y)); self } - #[must_use] + #[must_use] pub fn actions(&self) -> &[Action] { &self.actions } @@ -302,7 +302,7 @@ pub struct Cookie { } impl Cookie { - #[must_use] + #[must_use] pub fn new(name: &str, value: &str) -> Self { Self { name: name.to_string(), @@ -316,25 +316,25 @@ impl Cookie { } } - #[must_use] + #[must_use] pub fn with_domain(mut self, domain: &str) -> Self { self.domain = Some(domain.to_string()); self } - #[must_use] + #[must_use] pub fn with_path(mut self, path: &str) -> Self { self.path = Some(path.to_string()); self } - #[must_use] + #[must_use] pub const fn secure(mut self) -> Self { self.secure = Some(true); self } - #[must_use] + #[must_use] pub const fn http_only(mut self) -> Self { self.http_only = Some(true); self diff --git a/src/web/pages/mod.rs b/src/web/pages/mod.rs index a898f7d..e7c9947 100644 --- a/src/web/pages/mod.rs +++ b/src/web/pages/mod.rs @@ -23,7 +23,7 @@ pub struct LoginPage { } impl LoginPage { - #[must_use] + #[must_use] pub fn new(base_url: &str) -> Self { Self { base_url: base_url.to_string(), @@ -34,24 +34,24 @@ impl LoginPage { browser.goto(&format!("{}/login", self.base_url)).await } - #[must_use] + #[must_use] pub fn email_input() -> Locator { Locator::css("#email, input[name='email'], input[type='email']") } - #[must_use] + #[must_use] pub fn password_input() -> Locator { Locator::css("#password, input[name='password'], input[type='password']") } - #[must_use] + #[must_use] pub fn login_button() -> Locator { Locator::css( "#login-button, button[type='submit'], input[type='submit'], .login-btn, .btn-login", ) } - #[must_use] + #[must_use] pub fn error_message() -> Locator { Locator::css(".error, .error-message, .alert-error, .alert-danger, [role='alert']") } @@ -106,7 +106,7 @@ pub struct DashboardPage { } impl DashboardPage { - #[must_use] + #[must_use] pub fn new(base_url: &str) -> Self { Self { base_url: base_url.to_string(), @@ -117,22 +117,22 @@ impl DashboardPage { browser.goto(&format!("{}/dashboard", self.base_url)).await } - #[must_use] + #[must_use] pub fn stats_cards() -> Locator { Locator::css(".stats-card, .dashboard-stat, .metric-card") } - #[must_use] + #[must_use] pub fn nav_menu() -> Locator { Locator::css("nav, .nav, .sidebar, .navigation") } - #[must_use] + #[must_use] pub fn user_profile() -> Locator { Locator::css(".user-profile, .user-menu, .profile-dropdown, .avatar") } - #[must_use] + #[must_use] pub fn logout_button() -> Locator { Locator::css(".logout, .logout-btn, #logout, a[href*='logout'], button:contains('Logout')") } @@ -176,7 +176,7 @@ pub struct ChatPage { } impl ChatPage { - #[must_use] + #[must_use] pub fn new(base_url: &str, bot_name: &str) -> Self { Self { base_url: base_url.to_string(), @@ -190,44 +190,44 @@ impl ChatPage { .await } - #[must_use] + #[must_use] pub fn chat_input() -> Locator { Locator::css( "#chat-input, .chat-input, input[name='message'], textarea[name='message'], .message-input", ) } - #[must_use] + #[must_use] pub fn send_button() -> Locator { Locator::css("#send, .send-btn, button[type='submit'], .send-message") } - #[must_use] + #[must_use] pub fn message_list() -> Locator { Locator::css(".messages, .message-list, .chat-messages, #messages") } - #[must_use] + #[must_use] pub fn bot_message() -> Locator { Locator::css(".bot-message, .message-bot, .assistant-message, [data-role='bot']") } - #[must_use] + #[must_use] pub fn user_message() -> Locator { Locator::css(".user-message, .message-user, [data-role='user']") } - #[must_use] + #[must_use] pub fn typing_indicator() -> Locator { Locator::css(".typing, .typing-indicator, .is-typing, [data-typing]") } - #[must_use] + #[must_use] pub fn file_upload_button() -> Locator { Locator::css(".upload-btn, .file-upload, input[type='file'], .attach-file") } - #[must_use] + #[must_use] pub fn quick_reply_buttons() -> Locator { Locator::css(".quick-replies, .quick-reply, .suggested-reply") } @@ -319,7 +319,7 @@ pub struct QueuePage { } impl QueuePage { - #[must_use] + #[must_use] pub fn new(base_url: &str) -> Self { Self { base_url: base_url.to_string(), @@ -330,22 +330,22 @@ impl QueuePage { browser.goto(&format!("{}/queue", self.base_url)).await } - #[must_use] + #[must_use] pub fn queue_panel() -> Locator { Locator::css(".queue-panel, .queue-container, #queue-panel") } - #[must_use] + #[must_use] pub fn queue_count() -> Locator { Locator::css(".queue-count, .waiting-count, #queue-count") } - #[must_use] + #[must_use] pub fn queue_entry() -> Locator { Locator::css(".queue-entry, .queue-item, .waiting-customer") } - #[must_use] + #[must_use] pub fn take_next_button() -> Locator { Locator::css(".take-next, #take-next, button:contains('Take Next')") } @@ -383,7 +383,7 @@ pub struct BotManagementPage { } impl BotManagementPage { - #[must_use] + #[must_use] pub fn new(base_url: &str) -> Self { Self { base_url: base_url.to_string(), @@ -394,32 +394,32 @@ impl BotManagementPage { browser.goto(&format!("{}/admin/bots", self.base_url)).await } - #[must_use] + #[must_use] pub fn bot_list() -> Locator { Locator::css(".bot-list, .bots-container, #bots") } - #[must_use] + #[must_use] pub fn bot_item() -> Locator { Locator::css(".bot-item, .bot-card, .bot-entry") } - #[must_use] + #[must_use] pub fn create_bot_button() -> Locator { Locator::css(".create-bot, .new-bot, #create-bot, button:contains('Create')") } - #[must_use] + #[must_use] pub fn bot_name_input() -> Locator { Locator::css("#bot-name, input[name='name'], .bot-name-input") } - #[must_use] + #[must_use] pub fn bot_description_input() -> Locator { Locator::css("#bot-description, textarea[name='description'], .bot-description-input") } - #[must_use] + #[must_use] pub fn save_button() -> Locator { Locator::css(".save-btn, button[type='submit'], #save, button:contains('Save')") } @@ -469,7 +469,7 @@ pub struct KnowledgeBasePage { } impl KnowledgeBasePage { - #[must_use] + #[must_use] pub fn new(base_url: &str) -> Self { Self { base_url: base_url.to_string(), @@ -480,27 +480,27 @@ impl KnowledgeBasePage { browser.goto(&format!("{}/admin/kb", self.base_url)).await } - #[must_use] + #[must_use] pub fn kb_list() -> Locator { Locator::css(".kb-list, .knowledge-base-list, #kb-list") } - #[must_use] + #[must_use] pub fn kb_entry() -> Locator { Locator::css(".kb-entry, .kb-item, .knowledge-entry") } - #[must_use] + #[must_use] pub fn upload_button() -> Locator { Locator::css(".upload-btn, #upload, button:contains('Upload')") } - #[must_use] + #[must_use] pub fn file_input() -> Locator { Locator::css("input[type='file']") } - #[must_use] + #[must_use] pub fn search_input() -> Locator { Locator::css(".search-input, #search, input[placeholder*='search']") } @@ -532,7 +532,7 @@ pub struct AnalyticsPage { } impl AnalyticsPage { - #[must_use] + #[must_use] pub fn new(base_url: &str) -> Self { Self { base_url: base_url.to_string(), @@ -545,17 +545,17 @@ impl AnalyticsPage { .await } - #[must_use] + #[must_use] pub fn charts_container() -> Locator { Locator::css(".charts, .analytics-charts, #charts") } - #[must_use] + #[must_use] pub fn date_range_picker() -> Locator { Locator::css(".date-range, .date-picker, #date-range") } - #[must_use] + #[must_use] pub fn metric_card() -> Locator { Locator::css(".metric-card, .analytics-metric, .stat-card") } diff --git a/tests/e2e/mod.rs b/tests/e2e/mod.rs index dc87813..9b2ae38 100644 --- a/tests/e2e/mod.rs +++ b/tests/e2e/mod.rs @@ -201,7 +201,7 @@ pub fn browser_config() -> BrowserConfig { BrowserConfig::default() .with_browser(BrowserType::Chrome) .with_debug_port(debug_port) - .headless(headless) // false by default = show browser + .headless(headless) .with_timeout(Duration::from_secs(30)) .with_window_size(1920, 1080) } diff --git a/tests/integration/basic_runtime.rs b/tests/integration/basic_runtime.rs index d15b7da..bae502e 100644 --- a/tests/integration/basic_runtime.rs +++ b/tests/integration/basic_runtime.rs @@ -186,13 +186,13 @@ fn test_instr_function() { let engine = create_basic_engine(); let result: i64 = engine.eval(r#"INSTR("Hello World", "World")"#).unwrap(); - assert_eq!(result, 7); // 1-based index + assert_eq!(result, 7); let result: i64 = engine.eval(r#"INSTR("Hello World", "xyz")"#).unwrap(); - assert_eq!(result, 0); // Not found + assert_eq!(result, 0); let result: i64 = engine.eval(r#"INSTR("Hello World", "o")"#).unwrap(); - assert_eq!(result, 5); // First occurrence + assert_eq!(result, 5); } #[test] @@ -483,7 +483,7 @@ fn test_while_loop() { "#, ) .unwrap(); - assert_eq!(result, 10); // 0 + 1 + 2 + 3 + 4 = 10 + assert_eq!(result, 10); } @@ -494,7 +494,7 @@ fn test_division_by_zero() { let result = engine.eval::("10.0 / 0.0"); match result { Ok(val) => assert!(val.is_infinite() || val.is_nan()), - Err(_) => (), // Division by zero error is also acceptable + Err(_) => (), } } diff --git a/tests/unit/attendance/attendance.rs b/tests/unit/attendance/attendance.rs index 2428f1f..93443bf 100644 --- a/tests/unit/attendance/attendance.rs +++ b/tests/unit/attendance/attendance.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/attendance/mod.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,20 +7,20 @@ use serde_json; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_module_exports() { - // Test that types are properly exported + let _config = KeywordConfig::default(); let _parser = KeywordParser::new(); } #[test] - + fn test_respond_request_parse() { let json = r#"{ "session_id": "123e4567-e89b-12d3-a456-426614174000", diff --git a/tests/unit/attendance/attendance_llm_assist.rs b/tests/unit/attendance/attendance_llm_assist.rs index 87c8b07..5bf07e6 100644 --- a/tests/unit/attendance/attendance_llm_assist.rs +++ b/tests/unit/attendance/attendance_llm_assist.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/attendance/llm_assist.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_config_defaults() { let config = LlmAssistConfig::default(); assert!(!config.tips_enabled); @@ -18,7 +18,7 @@ #[test] - + fn test_fallback_tips_urgent() { let tips = generate_fallback_tips("This is URGENT! I need help immediately!"); assert!(!tips.is_empty()); @@ -27,7 +27,7 @@ #[test] - + fn test_fallback_tips_question() { let tips = generate_fallback_tips("How do I reset my password?"); assert!(!tips.is_empty()); @@ -36,7 +36,7 @@ #[test] - + fn test_sentiment_positive() { let sentiment = analyze_sentiment_keywords("Thank you so much! This is great!"); assert_eq!(sentiment.overall, "positive"); @@ -46,7 +46,7 @@ #[test] - + fn test_sentiment_negative() { let sentiment = analyze_sentiment_keywords("This is terrible! I'm very frustrated with this problem."); @@ -57,7 +57,7 @@ #[test] - + fn test_sentiment_urgent() { let sentiment = analyze_sentiment_keywords("I need help ASAP! This is urgent!"); assert!(sentiment.urgency == "high" || sentiment.urgency == "urgent"); @@ -65,7 +65,7 @@ #[test] - + fn test_extract_json() { let response = "Here is the result: {\"key\": \"value\"} and some more text."; let json = extract_json(response); @@ -74,7 +74,7 @@ #[test] - + fn test_fallback_replies() { let replies = generate_fallback_replies(); assert_eq!(replies.len(), 3); @@ -84,7 +84,7 @@ #[test] - + fn test_help_text() { let help = get_help_text(); assert!(help.contains("/queue")); diff --git a/tests/unit/attendance/mod.rs b/tests/unit/attendance/mod.rs index 31b34c1..c9c537d 100644 --- a/tests/unit/attendance/mod.rs +++ b/tests/unit/attendance/mod.rs @@ -1,3 +1,3 @@ -//! Tests for attendance module + mod attendance_llm_assist; mod attendance; diff --git a/tests/unit/basic/basic_compiler_goto_transform.rs b/tests/unit/basic/basic_compiler_goto_transform.rs index 779809f..f2aa034 100644 --- a/tests/unit/basic/basic_compiler_goto_transform.rs +++ b/tests/unit/basic/basic_compiler_goto_transform.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/compiler/goto_transform.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_is_label_line() { assert!(is_label_line("start:")); assert!(is_label_line(" mainLoop:")); @@ -24,7 +24,7 @@ #[test] - + fn test_extract_goto_target() { assert_eq!(extract_goto_target("GOTO start"), Some("start".to_string())); assert_eq!( @@ -40,7 +40,7 @@ #[test] - + fn test_transform_line_simple_goto() { assert_eq!( transform_line("GOTO start"), @@ -54,7 +54,7 @@ #[test] - + fn test_transform_line_if_then_goto() { let result = transform_line("IF x < 10 THEN GOTO start"); assert!(result.contains("if x < 10")); @@ -64,7 +64,7 @@ #[test] - + fn test_transform_line_if_goto_no_then() { let result = transform_line("IF x < 10 GOTO start"); assert!(result.contains("if x < 10")); @@ -73,7 +73,7 @@ #[test] - + fn test_transform_line_not_goto() { assert_eq!(transform_line("TALK \"Hello\""), "TALK \"Hello\""); assert_eq!(transform_line("x = x + 1"), "x = x + 1"); @@ -82,17 +82,17 @@ #[test] - + fn test_has_goto_constructs() { assert!(has_goto_constructs("start:\nTALK \"hi\"\nGOTO start")); assert!(has_goto_constructs("IF x > 0 THEN GOTO done")); assert!(!has_goto_constructs("TALK \"hello\"\nWAIT 1")); - assert!(!has_goto_constructs("ON ERROR GOTO 0")); // This is special, not regular GOTO + assert!(!has_goto_constructs("ON ERROR GOTO 0")); } #[test] - + fn test_transform_goto_simple() { let input = r#"start: TALK "Hello" @@ -110,16 +110,16 @@ #[test] - + fn test_transform_goto_no_goto() { let input = "TALK \"Hello\"\nTALK \"World\""; let output = transform_goto(input); - assert_eq!(output, input); // Unchanged + assert_eq!(output, input); } #[test] - + fn test_transform_goto_multiple_labels() { let input = r#"start: TALK "Start" @@ -139,7 +139,7 @@ done: #[test] - + fn test_infinite_loop_protection() { let output = transform_goto("loop:\nGOTO loop"); assert!(output.contains("__goto_max_iterations")); diff --git a/tests/unit/basic/basic_keywords_a2a_protocol.rs b/tests/unit/basic/basic_keywords_a2a_protocol.rs index 2a681c2..1af95a2 100644 --- a/tests/unit/basic/basic_keywords_a2a_protocol.rs +++ b/tests/unit/basic/basic_keywords_a2a_protocol.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/a2a_protocol.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use serde_json; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_a2a_message_creation() { let msg = A2AMessage::new( "bot_a", @@ -29,7 +29,7 @@ use serde_json; #[test] - + fn test_a2a_message_response() { let original = A2AMessage::new( "bot_a", @@ -50,7 +50,7 @@ use serde_json; #[test] - + fn test_message_type_display() { assert_eq!(A2AMessageType::Request.to_string(), "request"); assert_eq!(A2AMessageType::Response.to_string(), "response"); @@ -60,7 +60,7 @@ use serde_json; #[test] - + fn test_message_type_from_str() { assert_eq!(A2AMessageType::from("request"), A2AMessageType::Request); assert_eq!(A2AMessageType::from("RESPONSE"), A2AMessageType::Response); @@ -69,7 +69,7 @@ use serde_json; #[test] - + fn test_a2a_config_default() { let config = A2AConfig::default(); assert!(config.enabled); @@ -80,7 +80,7 @@ use serde_json; #[test] - + fn test_message_not_expired() { let msg = A2AMessage::new( "bot_a", @@ -95,7 +95,7 @@ use serde_json; #[test] - + fn test_max_hops_not_exceeded() { let msg = A2AMessage::new( "bot_a", @@ -110,7 +110,7 @@ use serde_json; #[test] - + fn test_max_hops_exceeded() { let mut msg = A2AMessage::new( "bot_a", diff --git a/tests/unit/basic/basic_keywords_add_bot.rs b/tests/unit/basic/basic_keywords_add_bot.rs index 7caf723..6198650 100644 --- a/tests/unit/basic/basic_keywords_add_bot.rs +++ b/tests/unit/basic/basic_keywords_add_bot.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/add_bot.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_trigger_from_keywords() { let trigger = BotTrigger::from_keywords(vec!["finance".to_string(), "money".to_string()]); assert_eq!(trigger.trigger_type, TriggerType::Keyword); @@ -17,7 +17,7 @@ #[test] - + fn test_match_bot_triggers() { let bots = vec![ SessionBot { @@ -57,7 +57,7 @@ #[test] - + fn test_match_tool_triggers() { let bots = vec![SessionBot { id: Uuid::new_v4(), diff --git a/tests/unit/basic/basic_keywords_add_member.rs b/tests/unit/basic/basic_keywords_add_member.rs index cf425bb..ff5a2aa 100644 --- a/tests/unit/basic/basic_keywords_add_member.rs +++ b/tests/unit/basic/basic_keywords_add_member.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/add_member.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_validate_role() { assert_eq!(validate_role("admin"), "admin"); assert_eq!(validate_role("ADMIN"), "admin"); @@ -19,7 +19,7 @@ #[test] - + fn test_get_permissions_for_role() { let admin_perms = get_permissions_for_role("admin"); assert!(admin_perms.get("read").unwrap().as_bool().unwrap()); diff --git a/tests/unit/basic/basic_keywords_add_suggestion.rs b/tests/unit/basic/basic_keywords_add_suggestion.rs index c64f263..1c768ea 100644 --- a/tests/unit/basic/basic_keywords_add_suggestion.rs +++ b/tests/unit/basic/basic_keywords_add_suggestion.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/add_suggestion.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_suggestion_json_context() { let suggestion = json!({ "type": "context", @@ -26,7 +26,7 @@ #[test] - + fn test_suggestion_json_tool_no_params() { let suggestion = json!({ "type": "tool", @@ -46,7 +46,7 @@ #[test] - + fn test_suggestion_json_tool_with_params() { let params = vec!["query".to_string(), "products".to_string()]; let suggestion = json!({ diff --git a/tests/unit/basic/basic_keywords_agent_reflection.rs b/tests/unit/basic/basic_keywords_agent_reflection.rs index b6ce473..18d8933 100644 --- a/tests/unit/basic/basic_keywords_agent_reflection.rs +++ b/tests/unit/basic/basic_keywords_agent_reflection.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/agent_reflection.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_reflection_type_from_str() { assert_eq!( ReflectionType::from("conversation_quality"), @@ -30,7 +30,7 @@ #[test] - + fn test_reflection_config_default() { let config = ReflectionConfig::default(); assert!(!config.enabled); @@ -40,7 +40,7 @@ #[test] - + fn test_reflection_result_new() { let bot_id = Uuid::new_v4(); let session_id = Uuid::new_v4(); @@ -54,7 +54,7 @@ #[test] - + fn test_reflection_result_from_json() { let json_response = r#"{ "score": 7.5, @@ -79,7 +79,7 @@ #[test] - + fn test_reflection_result_needs_improvement() { let mut result = ReflectionResult::new(Uuid::new_v4(), Uuid::new_v4(), ReflectionType::Performance); @@ -93,7 +93,7 @@ #[test] - + fn test_extract_insights_from_text() { let text = "Here are some insights:\n\ 1. Users prefer short responses\n\ @@ -107,7 +107,7 @@ #[test] - + fn test_reflection_type_prompt_template() { let template = ReflectionType::ConversationQuality.prompt_template(); assert!(template.contains("{conversation}")); @@ -116,7 +116,7 @@ #[test] - + fn test_reflection_result_summary() { let mut result = ReflectionResult::new(Uuid::new_v4(), Uuid::new_v4(), ReflectionType::Performance); @@ -128,6 +128,6 @@ let summary = result.summary(); assert!(summary.contains("7.5")); assert!(summary.contains("15")); - assert!(summary.contains("2")); // insights count - assert!(summary.contains("1")); // improvements count + assert!(summary.contains("2")); + assert!(summary.contains("1")); } \ No newline at end of file diff --git a/tests/unit/basic/basic_keywords_arrays.rs b/tests/unit/basic/basic_keywords_arrays.rs index 21896cc..7d811c4 100644 --- a/tests/unit/basic/basic_keywords_arrays.rs +++ b/tests/unit/basic/basic_keywords_arrays.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/arrays/mod.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -13,7 +13,7 @@ use rhai::Dynamic; #[test] - + fn test_ubound() { let arr: Vec = vec![Dynamic::from(1), Dynamic::from(2), Dynamic::from(3)]; assert_eq!(arr.len() - 1, 2); @@ -21,7 +21,7 @@ use rhai::Dynamic; #[test] - + fn test_join() { let arr = vec!["a", "b", "c"]; let result = arr.join("-"); @@ -30,7 +30,7 @@ use rhai::Dynamic; #[test] - + fn test_split() { let s = "a,b,c"; let parts: Vec<&str> = s.split(',').collect(); @@ -39,7 +39,7 @@ use rhai::Dynamic; #[test] - + fn test_range() { let range: Vec = (1..=5).collect(); assert_eq!(range, vec![1, 2, 3, 4, 5]); @@ -47,9 +47,9 @@ use rhai::Dynamic; #[test] - + fn test_flatten() { - // Test flattening logic + let nested = vec![vec![1, 2], vec![3, 4]]; let flat: Vec = nested.into_iter().flatten().collect(); assert_eq!(flat, vec![1, 2, 3, 4]); diff --git a/tests/unit/basic/basic_keywords_arrays_contains.rs b/tests/unit/basic/basic_keywords_arrays_contains.rs index e87c2f3..ba12afc 100644 --- a/tests/unit/basic/basic_keywords_arrays_contains.rs +++ b/tests/unit/basic/basic_keywords_arrays_contains.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/arrays/contains.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use rhai::Dynamic; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_contains_string() { let arr: Array = vec![ Dynamic::from("Alice"), @@ -25,7 +25,7 @@ use rhai::Dynamic; #[test] - + fn test_contains_integer() { let arr: Array = vec![ Dynamic::from(1_i64), @@ -39,7 +39,7 @@ use rhai::Dynamic; #[test] - + fn test_contains_float() { let arr: Array = vec![ Dynamic::from(1.5_f64), @@ -53,7 +53,7 @@ use rhai::Dynamic; #[test] - + fn test_contains_bool() { let arr: Array = vec![Dynamic::from(true), Dynamic::from(false)]; @@ -63,7 +63,7 @@ use rhai::Dynamic; #[test] - + fn test_contains_empty_array() { let arr = Array::new(); assert!(!array_contains(&arr, &Dynamic::from("anything"))); @@ -71,7 +71,7 @@ use rhai::Dynamic; #[test] - + fn test_items_equal_integers() { assert!(items_equal(&Dynamic::from(5_i64), &Dynamic::from(5_i64))); assert!(!items_equal(&Dynamic::from(5_i64), &Dynamic::from(6_i64))); @@ -79,7 +79,7 @@ use rhai::Dynamic; #[test] - + fn test_items_equal_strings() { assert!(items_equal( &Dynamic::from("hello"), diff --git a/tests/unit/basic/basic_keywords_arrays_push_pop.rs b/tests/unit/basic/basic_keywords_arrays_push_pop.rs index 5dba0f9..1c790a2 100644 --- a/tests/unit/basic/basic_keywords_arrays_push_pop.rs +++ b/tests/unit/basic/basic_keywords_arrays_push_pop.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/arrays/push_pop.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -13,7 +13,7 @@ use rhai::Dynamic; #[test] - + fn test_push() { let mut arr: Array = vec![Dynamic::from(1), Dynamic::from(2)]; arr.push(Dynamic::from(3)); @@ -23,7 +23,7 @@ use rhai::Dynamic; #[test] - + fn test_pop() { let mut arr: Array = vec![Dynamic::from(1), Dynamic::from(2), Dynamic::from(3)]; let popped = arr.pop(); @@ -33,7 +33,7 @@ use rhai::Dynamic; #[test] - + fn test_pop_empty() { let mut arr: Array = vec![]; let popped = arr.pop(); @@ -42,7 +42,7 @@ use rhai::Dynamic; #[test] - + fn test_shift() { let mut arr: Array = vec![Dynamic::from(1), Dynamic::from(2), Dynamic::from(3)]; let shifted = arr.remove(0); @@ -53,7 +53,7 @@ use rhai::Dynamic; #[test] - + fn test_unshift() { let mut arr: Array = vec![Dynamic::from(2), Dynamic::from(3)]; arr.insert(0, Dynamic::from(1)); diff --git a/tests/unit/basic/basic_keywords_arrays_slice.rs b/tests/unit/basic/basic_keywords_arrays_slice.rs index 00d0dba..e24a214 100644 --- a/tests/unit/basic/basic_keywords_arrays_slice.rs +++ b/tests/unit/basic/basic_keywords_arrays_slice.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/arrays/slice.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,7 +7,7 @@ use rhai::Dynamic; -// Original: use super::*; - tests used internal functions from botserver + fn make_test_array() -> Array { vec![ @@ -21,7 +21,7 @@ use rhai::Dynamic; #[test] - + fn test_slice_from_start() { let arr = make_test_array(); let result = slice_array(&arr, 2, None); @@ -31,7 +31,7 @@ use rhai::Dynamic; #[test] - + fn test_slice_with_end() { let arr = make_test_array(); let result = slice_array(&arr, 1, Some(3)); @@ -42,7 +42,7 @@ use rhai::Dynamic; #[test] - + fn test_slice_negative_start() { let arr = make_test_array(); let result = slice_array(&arr, -2, None); @@ -53,7 +53,7 @@ use rhai::Dynamic; #[test] - + fn test_slice_negative_end() { let arr = make_test_array(); let result = slice_array(&arr, 0, Some(-2)); @@ -64,7 +64,7 @@ use rhai::Dynamic; #[test] - + fn test_slice_out_of_bounds() { let arr = make_test_array(); let result = slice_array(&arr, 10, None); @@ -73,7 +73,7 @@ use rhai::Dynamic; #[test] - + fn test_slice_empty_range() { let arr = make_test_array(); let result = slice_array(&arr, 3, Some(2)); diff --git a/tests/unit/basic/basic_keywords_arrays_sort.rs b/tests/unit/basic/basic_keywords_arrays_sort.rs index 1166650..44aad38 100644 --- a/tests/unit/basic/basic_keywords_arrays_sort.rs +++ b/tests/unit/basic/basic_keywords_arrays_sort.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/arrays/sort.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use rhai::Dynamic; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_sort_integers() { let arr: Array = vec![ Dynamic::from(3), @@ -30,7 +30,7 @@ use rhai::Dynamic; #[test] - + fn test_sort_strings() { let arr: Array = vec![ Dynamic::from("banana"), @@ -45,7 +45,7 @@ use rhai::Dynamic; #[test] - + fn test_sort_descending() { let arr: Array = vec![Dynamic::from(1), Dynamic::from(3), Dynamic::from(2)]; let sorted = sort_array(arr, true); @@ -56,7 +56,7 @@ use rhai::Dynamic; #[test] - + fn test_compare_dynamic_numbers() { let a = Dynamic::from(5); let b = Dynamic::from(3); @@ -65,7 +65,7 @@ use rhai::Dynamic; #[test] - + fn test_compare_dynamic_strings() { let a = Dynamic::from("apple"); let b = Dynamic::from("banana"); diff --git a/tests/unit/basic/basic_keywords_arrays_unique.rs b/tests/unit/basic/basic_keywords_arrays_unique.rs index 92275c3..2b594b5 100644 --- a/tests/unit/basic/basic_keywords_arrays_unique.rs +++ b/tests/unit/basic/basic_keywords_arrays_unique.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/arrays/unique.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,12 +7,12 @@ use rhai::Dynamic; -// Original: use super::*; - tests used internal functions from botserver + use rhai::Dynamic; #[test] - + fn test_unique_integers() { let mut arr = Array::new(); arr.push(Dynamic::from(1_i64)); @@ -29,7 +29,7 @@ use rhai::Dynamic; #[test] - + fn test_unique_strings() { let mut arr = Array::new(); arr.push(Dynamic::from("Alice")); @@ -43,7 +43,7 @@ use rhai::Dynamic; #[test] - + fn test_unique_preserves_order() { let mut arr = Array::new(); arr.push(Dynamic::from("C")); @@ -61,7 +61,7 @@ use rhai::Dynamic; #[test] - + fn test_unique_empty_array() { let arr = Array::new(); let result = unique_array(arr); @@ -70,7 +70,7 @@ use rhai::Dynamic; #[test] - + fn test_unique_single_element() { let mut arr = Array::new(); arr.push(Dynamic::from(42_i64)); @@ -81,7 +81,7 @@ use rhai::Dynamic; #[test] - + fn test_unique_all_same() { let mut arr = Array::new(); arr.push(Dynamic::from(1_i64)); @@ -94,7 +94,7 @@ use rhai::Dynamic; #[test] - + fn test_unique_mixed_types() { let mut arr = Array::new(); arr.push(Dynamic::from(1_i64)); @@ -102,7 +102,7 @@ use rhai::Dynamic; arr.push(Dynamic::from(1_i64)); let result = unique_array(arr); - // "1" (int) and "1" (string) may have same string representation - // so behavior depends on Dynamic::to_string() implementation + + assert!(result.len() >= 1 && result.len() <= 2); } \ No newline at end of file diff --git a/tests/unit/basic/basic_keywords_book.rs b/tests/unit/basic/basic_keywords_book.rs index f8cc4e6..d0862b2 100644 --- a/tests/unit/basic/basic_keywords_book.rs +++ b/tests/unit/basic/basic_keywords_book.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/book.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_parse_time_string() { let result = parse_time_string("2024-01-15 14:30"); assert!(result.is_ok()); @@ -22,7 +22,7 @@ #[test] - + fn test_parse_date_string() { let result = parse_date_string("today"); assert!(result.is_ok()); @@ -36,7 +36,7 @@ #[test] - + fn test_extract_hour() { assert_eq!(extract_hour_from_string("3pm"), Some(15)); assert_eq!(extract_hour_from_string("3 PM"), Some(15)); diff --git a/tests/unit/basic/basic_keywords_card.rs b/tests/unit/basic/basic_keywords_card.rs index 1123103..7a42ebc 100644 --- a/tests/unit/basic/basic_keywords_card.rs +++ b/tests/unit/basic/basic_keywords_card.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/card.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_card_style_from_string() { assert!(matches!(CardStyle::from("minimal"), CardStyle::Minimal)); assert!(matches!(CardStyle::from("VIBRANT"), CardStyle::Vibrant)); @@ -18,7 +18,7 @@ #[test] - + fn test_card_dimensions_for_style() { let story_dims = CardDimensions::for_style(&CardStyle::Story); assert_eq!(story_dims.width, 1080); @@ -31,7 +31,7 @@ #[test] - + fn test_card_config_default() { let config = CardConfig::default(); assert!(matches!(config.style, CardStyle::Modern)); diff --git a/tests/unit/basic/basic_keywords_clear_kb.rs b/tests/unit/basic/basic_keywords_clear_kb.rs index 782c29f..facd48d 100644 --- a/tests/unit/basic/basic_keywords_clear_kb.rs +++ b/tests/unit/basic/basic_keywords_clear_kb.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/clear_kb.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -8,20 +8,20 @@ use rhai::Dynamic; use rhai::Engine; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_clear_kb_syntax() { let mut engine = Engine::new(); - // Test CLEAR_KB with argument + assert!(engine .register_custom_syntax(&["CLEAR_KB", "$expr$"], true, |_, _| Ok(Dynamic::UNIT)) .is_ok()); - // Test CLEAR_KB without argument + assert!(engine .register_custom_syntax(&["CLEAR_KB"], true, |_, _| Ok(Dynamic::UNIT)) .is_ok()); diff --git a/tests/unit/basic/basic_keywords_code_sandbox.rs b/tests/unit/basic/basic_keywords_code_sandbox.rs index c962dd3..af35dd0 100644 --- a/tests/unit/basic/basic_keywords_code_sandbox.rs +++ b/tests/unit/basic/basic_keywords_code_sandbox.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/code_sandbox.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_sandbox_config_default() { let config = SandboxConfig::default(); assert!(config.enabled); @@ -19,7 +19,7 @@ #[test] - + fn test_execution_result_success() { let result = ExecutionResult::success("Hello, World!".to_string(), String::new(), 100); assert!(result.is_success()); @@ -28,7 +28,7 @@ #[test] - + fn test_execution_result_error() { let result = ExecutionResult::error("Something went wrong"); assert!(!result.is_success()); @@ -37,7 +37,7 @@ #[test] - + fn test_execution_result_timeout() { let result = ExecutionResult::timeout(); assert!(!result.is_success()); @@ -46,7 +46,7 @@ #[test] - + fn test_code_language_from_str() { assert_eq!(CodeLanguage::from("python"), CodeLanguage::Python); assert_eq!(CodeLanguage::from("PYTHON"), CodeLanguage::Python); @@ -59,7 +59,7 @@ #[test] - + fn test_code_language_file_extension() { assert_eq!(CodeLanguage::Python.file_extension(), "py"); assert_eq!(CodeLanguage::JavaScript.file_extension(), "js"); @@ -68,7 +68,7 @@ #[test] - + fn test_code_language_interpreter() { assert_eq!(CodeLanguage::Python.interpreter(), "python3"); assert_eq!(CodeLanguage::JavaScript.interpreter(), "node"); @@ -77,7 +77,7 @@ #[test] - + fn test_sandbox_runtime_from_str() { assert_eq!(SandboxRuntime::from("lxc"), SandboxRuntime::LXC); assert_eq!(SandboxRuntime::from("docker"), SandboxRuntime::Docker); @@ -90,7 +90,7 @@ #[test] - + fn test_lxc_config_generation() { let python_config = generate_python_lxc_config(); assert!(python_config.contains("gb-sandbox-python")); diff --git a/tests/unit/basic/basic_keywords_core_functions.rs b/tests/unit/basic/basic_keywords_core_functions.rs index 550d14c..c243b29 100644 --- a/tests/unit/basic/basic_keywords_core_functions.rs +++ b/tests/unit/basic/basic_keywords_core_functions.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/core_functions.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -9,9 +9,9 @@ #[test] - + fn test_module_structure() { - // This test verifies the module compiles correctly - // Actual function tests are in their respective submodules + + assert!(true); } \ No newline at end of file diff --git a/tests/unit/basic/basic_keywords_create_task.rs b/tests/unit/basic/basic_keywords_create_task.rs index 04e34a6..b054f07 100644 --- a/tests/unit/basic/basic_keywords_create_task.rs +++ b/tests/unit/basic/basic_keywords_create_task.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/create_task.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_parse_due_date() { assert!(parse_due_date("tomorrow").is_ok()); assert!(parse_due_date("+3 days").is_ok()); @@ -18,7 +18,7 @@ #[test] - + fn test_determine_priority() { let tomorrow = Some(Utc::now() + Duration::days(1)); assert_eq!(determine_priority(tomorrow), "high"); diff --git a/tests/unit/basic/basic_keywords_crm_attendance.rs b/tests/unit/basic/basic_keywords_crm_attendance.rs index 238f968..b549019 100644 --- a/tests/unit/basic/basic_keywords_crm_attendance.rs +++ b/tests/unit/basic/basic_keywords_crm_attendance.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/crm/attendance.rs -//! These tests were originally in botserver and have been migrated to bottest. + + use botserver::basic::keywords::crm::attendance::create_fallback_tips; use rhai::Map; diff --git a/tests/unit/basic/basic_keywords_crm_score_lead.rs b/tests/unit/basic/basic_keywords_crm_score_lead.rs index da62ad4..ebbd965 100644 --- a/tests/unit/basic/basic_keywords_crm_score_lead.rs +++ b/tests/unit/basic/basic_keywords_crm_score_lead.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/crm/score_lead.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use rhai::Dynamic; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_calculate_lead_score_empty() { let lead_data = Map::new(); let score = calculate_lead_score(&lead_data, None); @@ -20,7 +20,7 @@ use rhai::Dynamic; #[test] - + fn test_calculate_lead_score_basic() { let mut lead_data = Map::new(); lead_data.insert("job_title".into(), Dynamic::from("CEO")); @@ -28,12 +28,12 @@ use rhai::Dynamic; lead_data.insert("email".into(), Dynamic::from("ceo@company.com")); let score = calculate_lead_score(&lead_data, None); - assert!(score > 30); // At least CEO bonus + assert!(score > 30); } #[test] - + fn test_calculate_lead_score_with_title() { let mut lead_data = Map::new(); lead_data.insert("job_title".into(), Dynamic::from("CTO")); @@ -44,7 +44,7 @@ use rhai::Dynamic; #[test] - + fn test_determine_priority() { assert_eq!(determine_priority(95), "CRITICAL"); assert_eq!(determine_priority(75), "HIGH"); @@ -55,7 +55,7 @@ use rhai::Dynamic; #[test] - + fn test_score_clamping() { let mut lead_data = Map::new(); lead_data.insert("budget".into(), Dynamic::from(1000000_i64)); diff --git a/tests/unit/basic/basic_keywords_data_operations.rs b/tests/unit/basic/basic_keywords_data_operations.rs index 1987691..94fcd6f 100644 --- a/tests/unit/basic/basic_keywords_data_operations.rs +++ b/tests/unit/basic/basic_keywords_data_operations.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/data_operations.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_sanitize_identifier() { assert_eq!(sanitize_identifier("users"), "users"); assert_eq!(sanitize_identifier("user_name"), "user_name"); @@ -20,7 +20,7 @@ #[test] - + fn test_sanitize_sql() { assert_eq!(sanitize_sql("hello"), "hello"); assert_eq!(sanitize_sql("it's"), "it''s"); @@ -29,7 +29,7 @@ #[test] - + fn test_parse_condition() { let (field, op, value) = parse_condition_internal("status=active").unwrap(); assert_eq!(field, "status"); @@ -44,7 +44,7 @@ #[test] - + fn test_parse_filter_clause() { let clause = parse_filter_clause("name=John").unwrap(); assert!(clause.contains("name")); diff --git a/tests/unit/basic/basic_keywords_datetime_dateadd.rs b/tests/unit/basic/basic_keywords_datetime_dateadd.rs index f06b8b9..84cca3b 100644 --- a/tests/unit/basic/basic_keywords_datetime_dateadd.rs +++ b/tests/unit/basic/basic_keywords_datetime_dateadd.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/datetime/dateadd.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_dateadd_days() { assert_eq!(dateadd_impl("2025-01-15", 5, "day"), "2025-01-20"); assert_eq!(dateadd_impl("2025-01-15", -10, "day"), "2025-01-05"); @@ -16,7 +16,7 @@ #[test] - + fn test_dateadd_months() { assert_eq!(dateadd_impl("2025-01-15", 1, "month"), "2025-02-15"); assert_eq!(dateadd_impl("2025-01-15", -1, "month"), "2024-12-15"); @@ -24,14 +24,14 @@ #[test] - + fn test_dateadd_years() { assert_eq!(dateadd_impl("2025-01-15", 1, "year"), "2026-01-15"); } #[test] - + fn test_datediff_days() { assert_eq!(datediff_impl("2025-01-01", "2025-01-15", "day"), 14); assert_eq!(datediff_impl("2025-01-15", "2025-01-01", "day"), -14); @@ -39,21 +39,21 @@ #[test] - + fn test_datediff_months() { assert_eq!(datediff_impl("2025-01-01", "2025-03-01", "month"), 2); } #[test] - + fn test_datediff_years() { assert_eq!(datediff_impl("2024-01-01", "2025-01-01", "year"), 1); } #[test] - + fn test_parse_date() { assert!(parse_date("2025-01-15").is_some()); assert!(parse_date("15/01/2025").is_some()); diff --git a/tests/unit/basic/basic_keywords_datetime_extract.rs b/tests/unit/basic/basic_keywords_datetime_extract.rs index 08daee8..1a807cf 100644 --- a/tests/unit/basic/basic_keywords_datetime_extract.rs +++ b/tests/unit/basic/basic_keywords_datetime_extract.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/datetime/extract.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_parse_date() { let date = parse_date("2025-01-22"); assert!(date.is_some()); @@ -20,7 +20,7 @@ #[test] - + fn test_parse_datetime() { let dt = parse_datetime("2025-01-22 14:30:45"); assert!(dt.is_some()); @@ -32,7 +32,7 @@ #[test] - + fn test_invalid_date() { let date = parse_date("invalid"); assert!(date.is_none()); diff --git a/tests/unit/basic/basic_keywords_datetime_now.rs b/tests/unit/basic/basic_keywords_datetime_now.rs index 4cbef30..9d11937 100644 --- a/tests/unit/basic/basic_keywords_datetime_now.rs +++ b/tests/unit/basic/basic_keywords_datetime_now.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/datetime/now.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_create_datetime_map() { let now = Local::now(); let map = create_datetime_map(now); @@ -28,7 +28,7 @@ #[test] - + fn test_year_extraction() { let now = Local::now(); let map = create_datetime_map(now); @@ -39,7 +39,7 @@ #[test] - + fn test_month_range() { let now = Local::now(); let map = create_datetime_map(now); @@ -50,7 +50,7 @@ #[test] - + fn test_hour12_range() { let now = Local::now(); let map = create_datetime_map(now); @@ -61,7 +61,7 @@ #[test] - + fn test_quarter_calculation() { let now = Local::now(); let map = create_datetime_map(now); diff --git a/tests/unit/basic/basic_keywords_episodic_memory.rs b/tests/unit/basic/basic_keywords_episodic_memory.rs index 1ebe060..176f171 100644 --- a/tests/unit/basic/basic_keywords_episodic_memory.rs +++ b/tests/unit/basic/basic_keywords_episodic_memory.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/episodic_memory.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use serde_json; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_default_config() { let config = EpisodicMemoryConfig::default(); assert!(config.enabled); @@ -22,7 +22,7 @@ use serde_json; #[test] - + fn test_should_summarize() { let manager = EpisodicMemoryManager::new(EpisodicMemoryConfig { enabled: true, @@ -39,20 +39,20 @@ use serde_json; #[test] - + fn test_extract_json() { - // Test with code block + let response = "Here's the summary:\n```json\n{\"summary\": \"test\"}\n```\n"; assert!(extract_json(response).is_ok()); - // Test with raw JSON + let response = "The result is {\"summary\": \"test\"}"; assert!(extract_json(response).is_ok()); } #[test] - + fn test_generate_summary_prompt() { let manager = EpisodicMemoryManager::new(EpisodicMemoryConfig::default()); let messages = vec![ConversationMessage { @@ -69,7 +69,7 @@ use serde_json; #[test] - + fn test_parse_summary_response() { let manager = EpisodicMemoryManager::new(EpisodicMemoryConfig::default()); let response = r#"{ @@ -105,7 +105,7 @@ use serde_json; #[test] - + fn test_episode_to_dynamic() { let episode = Episode { id: Uuid::new_v4(), diff --git a/tests/unit/basic/basic_keywords_errors.rs b/tests/unit/basic/basic_keywords_errors.rs index a63182f..a9042c2 100644 --- a/tests/unit/basic/basic_keywords_errors.rs +++ b/tests/unit/basic/basic_keywords_errors.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/errors/mod.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -12,7 +12,7 @@ use rhai::Dynamic; #[test] - + fn test_error_map() { use rhai::{Dynamic, Map}; diff --git a/tests/unit/basic/basic_keywords_errors_on_error.rs b/tests/unit/basic/basic_keywords_errors_on_error.rs index 11e8061..2d33fff 100644 --- a/tests/unit/basic/basic_keywords_errors_on_error.rs +++ b/tests/unit/basic/basic_keywords_errors_on_error.rs @@ -1,30 +1,30 @@ -//! Unit tests migrated from src/basic/keywords/errors/on_error.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_error_resume_next_flag() { - // Initially should be false + assert!(!is_error_resume_next_active()); - // Enable it + set_error_resume_next(true); assert!(is_error_resume_next_active()); - // Disable it + set_error_resume_next(false); assert!(!is_error_resume_next_active()); } #[test] - + fn test_error_storage() { clear_last_error(); assert!(get_last_error().is_none()); @@ -41,7 +41,7 @@ #[test] - + fn test_handle_error_without_resume_next() { set_error_resume_next(false); clear_last_error(); @@ -50,13 +50,13 @@ Err("Test error".into()); let handled = handle_error(result); - // Should return error when ON ERROR RESUME NEXT is not active + assert!(handled.is_err()); } #[test] - + fn test_handle_error_with_resume_next() { set_error_resume_next(true); clear_last_error(); @@ -65,10 +65,10 @@ Err("Test error".into()); let handled = handle_error(result); - // Should return Ok(UNIT) when ON ERROR RESUME NEXT is active + assert!(handled.is_ok()); assert_eq!(get_last_error(), Some("Test error".to_string())); - // Cleanup + set_error_resume_next(false); } \ No newline at end of file diff --git a/tests/unit/basic/basic_keywords_errors_throw.rs b/tests/unit/basic/basic_keywords_errors_throw.rs index a66127a..e410e83 100644 --- a/tests/unit/basic/basic_keywords_errors_throw.rs +++ b/tests/unit/basic/basic_keywords_errors_throw.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/errors/throw.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -9,8 +9,8 @@ #[test] - + fn test_placeholder() { - // Placeholder test - actual functionality is in mod.rs + assert!(true); } \ No newline at end of file diff --git a/tests/unit/basic/basic_keywords_file_operations.rs b/tests/unit/basic/basic_keywords_file_operations.rs index 63ffe7b..74dcdb0 100644 --- a/tests/unit/basic/basic_keywords_file_operations.rs +++ b/tests/unit/basic/basic_keywords_file_operations.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/file_operations.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use rhai::Dynamic; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_dynamic_to_json() { let dynamic = Dynamic::from("hello"); let json = dynamic_to_json(&dynamic); @@ -20,7 +20,7 @@ use rhai::Dynamic; #[test] - + fn test_dynamic_to_file_data() { let dynamic = Dynamic::from("test content"); let file_data = dynamic_to_file_data(&dynamic); diff --git a/tests/unit/basic/basic_keywords_hear_talk.rs b/tests/unit/basic/basic_keywords_hear_talk.rs index 21ec110..f95711b 100644 --- a/tests/unit/basic/basic_keywords_hear_talk.rs +++ b/tests/unit/basic/basic_keywords_hear_talk.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/hear_talk.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_validate_email() { assert!(validate_email("test@example.com").is_valid); assert!(validate_email("user.name+tag@domain.co.uk").is_valid); @@ -18,7 +18,7 @@ #[test] - + fn test_validate_date() { assert!(validate_date("25/12/2024").is_valid); assert!(validate_date("2024-12-25").is_valid); @@ -29,7 +29,7 @@ #[test] - + fn test_validate_cpf() { assert!(validate_cpf("529.982.247-25").is_valid); assert!(validate_cpf("52998224725").is_valid); @@ -39,7 +39,7 @@ #[test] - + fn test_validate_money() { let result = validate_money("R$ 1.234,56"); assert!(result.is_valid); @@ -52,7 +52,7 @@ #[test] - + fn test_validate_boolean() { assert!(validate_boolean("yes").is_valid); assert!(validate_boolean("sim").is_valid); @@ -63,7 +63,7 @@ #[test] - + fn test_validate_menu() { let options = vec![ "Apple".to_string(), @@ -73,16 +73,16 @@ assert!(validate_menu("Apple", &options).is_valid); assert!(validate_menu("1", &options).is_valid); - assert!(validate_menu("ban", &options).is_valid); // Partial match + assert!(validate_menu("ban", &options).is_valid); assert!(!validate_menu("Orange", &options).is_valid); } #[test] - + fn test_validate_credit_card() { - // Valid Visa test number + assert!(validate_credit_card("4111 1111 1111 1111").is_valid); - // Invalid (fails Luhn) + assert!(!validate_credit_card("1234567890123456").is_valid); } \ No newline at end of file diff --git a/tests/unit/basic/basic_keywords_http_operations.rs b/tests/unit/basic/basic_keywords_http_operations.rs index 665e670..c27b706 100644 --- a/tests/unit/basic/basic_keywords_http_operations.rs +++ b/tests/unit/basic/basic_keywords_http_operations.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/http_operations.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use rhai::Dynamic; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_dynamic_to_json_string() { let dynamic = Dynamic::from("hello"); let json = dynamic_to_json(&dynamic); @@ -20,7 +20,7 @@ use rhai::Dynamic; #[test] - + fn test_dynamic_to_json_number() { let dynamic = Dynamic::from(42_i64); let json = dynamic_to_json(&dynamic); @@ -29,7 +29,7 @@ use rhai::Dynamic; #[test] - + fn test_build_soap_envelope() { let params = json!({"name": "John", "age": 30}); let envelope = build_soap_envelope("GetUser", ¶ms); @@ -40,7 +40,7 @@ use rhai::Dynamic; #[test] - + fn test_parse_soap_response() { let xml = r#"Success"#; let result = parse_soap_response(xml); diff --git a/tests/unit/basic/basic_keywords_human_approval.rs b/tests/unit/basic/basic_keywords_human_approval.rs index 721b295..de3b01b 100644 --- a/tests/unit/basic/basic_keywords_human_approval.rs +++ b/tests/unit/basic/basic_keywords_human_approval.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/human_approval.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use serde_json; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_default_config() { let config = ApprovalConfig::default(); assert!(config.enabled); @@ -21,7 +21,7 @@ use serde_json; #[test] - + fn test_create_request() { let manager = ApprovalManager::new(ApprovalConfig::default()); let request = manager.create_request( @@ -44,7 +44,7 @@ use serde_json; #[test] - + fn test_is_expired() { let manager = ApprovalManager::new(ApprovalConfig::default()); let mut request = manager.create_request( @@ -56,20 +56,20 @@ use serde_json; "test@example.com", serde_json::json!({}), "Test", - Some(1), // 1 second timeout + Some(1), None, ); assert!(!manager.is_expired(&request)); - // Manually set expired time + request.expires_at = Utc::now() - Duration::seconds(10); assert!(manager.is_expired(&request)); } #[test] - + fn test_process_decision() { let manager = ApprovalManager::new(ApprovalConfig::default()); let mut request = manager.create_request( @@ -100,7 +100,7 @@ use serde_json; #[test] - + fn test_evaluate_condition() { let manager = ApprovalManager::new(ApprovalConfig::default()); let context = serde_json::json!({ @@ -121,7 +121,7 @@ use serde_json; #[test] - + fn test_handle_timeout_with_default() { let manager = ApprovalManager::new(ApprovalConfig::default()); let mut request = manager.create_request( @@ -146,7 +146,7 @@ use serde_json; #[test] - + fn test_request_to_dynamic() { let manager = ApprovalManager::new(ApprovalConfig::default()); let request = manager.create_request( diff --git a/tests/unit/basic/basic_keywords_import_export.rs b/tests/unit/basic/basic_keywords_import_export.rs index b787c81..2f533f3 100644 --- a/tests/unit/basic/basic_keywords_import_export.rs +++ b/tests/unit/basic/basic_keywords_import_export.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/import_export.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use serde_json; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_parse_csv_line_simple() { let line = "a,b,c"; let result = parse_csv_line(line); @@ -20,7 +20,7 @@ use serde_json; #[test] - + fn test_parse_csv_line_quoted() { let line = r#""hello, world",test,"another, value""#; let result = parse_csv_line(line); @@ -29,7 +29,7 @@ use serde_json; #[test] - + fn test_escape_csv_value() { assert_eq!(escape_csv_value("simple"), "simple"); assert_eq!(escape_csv_value("with,comma"), "\"with,comma\""); @@ -38,7 +38,7 @@ use serde_json; #[test] - + fn test_json_to_dynamic_and_back() { let json = serde_json::json!({ "name": "test", diff --git a/tests/unit/basic/basic_keywords_kb_statistics.rs b/tests/unit/basic/basic_keywords_kb_statistics.rs index bde9d01..4fee012 100644 --- a/tests/unit/basic/basic_keywords_kb_statistics.rs +++ b/tests/unit/basic/basic_keywords_kb_statistics.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/kb_statistics.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use serde_json; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_collection_stats_serialization() { let stats = CollectionStats { name: "test_collection".to_string(), @@ -31,7 +31,7 @@ use serde_json; #[test] - + fn test_kb_statistics_serialization() { let stats = KBStatistics { total_collections: 3, diff --git a/tests/unit/basic/basic_keywords_knowledge_graph.rs b/tests/unit/basic/basic_keywords_knowledge_graph.rs index 0d8eb1a..ace5a32 100644 --- a/tests/unit/basic/basic_keywords_knowledge_graph.rs +++ b/tests/unit/basic/basic_keywords_knowledge_graph.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/knowledge_graph.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use serde_json; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_default_config() { let config = KnowledgeGraphConfig::default(); assert!(config.enabled); @@ -21,7 +21,7 @@ use serde_json; #[test] - + fn test_extraction_prompt() { let manager = KnowledgeGraphManager::new(KnowledgeGraphConfig::default()); let prompt = manager.generate_extraction_prompt("John works at Acme Corp."); @@ -31,7 +31,7 @@ use serde_json; #[test] - + fn test_parse_extraction_response() { let manager = KnowledgeGraphManager::new(KnowledgeGraphConfig::default()); let response = r#"{ @@ -64,7 +64,7 @@ use serde_json; #[test] - + fn test_entity_to_dynamic() { let entity = KgEntity { id: Uuid::new_v4(), @@ -85,7 +85,7 @@ use serde_json; #[test] - + fn test_is_valid_entity_type() { let manager = KnowledgeGraphManager::new(KnowledgeGraphConfig::default()); assert!(manager.is_valid_entity_type("person")); @@ -96,7 +96,7 @@ use serde_json; #[test] - + fn test_json_to_dynamic() { let json = serde_json::json!({ "name": "test", diff --git a/tests/unit/basic/basic_keywords_lead_scoring.rs b/tests/unit/basic/basic_keywords_lead_scoring.rs index dce108c..c243b29 100644 --- a/tests/unit/basic/basic_keywords_lead_scoring.rs +++ b/tests/unit/basic/basic_keywords_lead_scoring.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/lead_scoring.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -9,9 +9,9 @@ #[test] - + fn test_module_structure() { - // This test verifies the module compiles correctly - // Actual function tests are in the crm/score_lead.rs module + + assert!(true); } \ No newline at end of file diff --git a/tests/unit/basic/basic_keywords_llm_macros.rs b/tests/unit/basic/basic_keywords_llm_macros.rs index ca86473..48f11df 100644 --- a/tests/unit/basic/basic_keywords_llm_macros.rs +++ b/tests/unit/basic/basic_keywords_llm_macros.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/llm_macros.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_parse_calculate_result_integer() { let result = parse_calculate_result("42").unwrap(); assert_eq!(result.as_int().unwrap(), 42); @@ -16,7 +16,7 @@ #[test] - + fn test_parse_calculate_result_float() { let result = parse_calculate_result("3.14").unwrap(); assert!((result.as_float().unwrap() - 3.14).abs() < 0.001); @@ -24,7 +24,7 @@ #[test] - + fn test_parse_calculate_result_boolean() { let result = parse_calculate_result("true").unwrap(); assert!(result.as_bool().unwrap()); @@ -32,7 +32,7 @@ #[test] - + fn test_build_translate_prompt() { let prompt = build_translate_prompt("Hello", "Spanish"); assert!(prompt.contains("Hello")); diff --git a/tests/unit/basic/basic_keywords_math_abs.rs b/tests/unit/basic/basic_keywords_math_abs.rs index 179421d..b577ea6 100644 --- a/tests/unit/basic/basic_keywords_math_abs.rs +++ b/tests/unit/basic/basic_keywords_math_abs.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/math/abs.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -9,7 +9,7 @@ #[test] - + fn test_abs_positive() { assert_eq!(42_i64.abs(), 42); assert_eq!(3.14_f64.abs(), 3.14); @@ -17,7 +17,7 @@ #[test] - + fn test_abs_negative() { assert_eq!((-42_i64).abs(), 42); assert_eq!((-3.14_f64).abs(), 3.14); @@ -25,7 +25,7 @@ #[test] - + fn test_abs_zero() { assert_eq!(0_i64.abs(), 0); assert_eq!(0.0_f64.abs(), 0.0); diff --git a/tests/unit/basic/basic_keywords_math_aggregate.rs b/tests/unit/basic/basic_keywords_math_aggregate.rs index 89bf046..686c018 100644 --- a/tests/unit/basic/basic_keywords_math_aggregate.rs +++ b/tests/unit/basic/basic_keywords_math_aggregate.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/math/aggregate.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -13,7 +13,7 @@ use rhai::Dynamic; #[test] - + fn test_sum() { let arr: Vec = vec![ Dynamic::from(10_i64), @@ -29,7 +29,7 @@ use rhai::Dynamic; #[test] - + fn test_avg() { let arr: Vec = vec![10.0, 20.0, 30.0]; let sum: f64 = arr.iter().sum(); @@ -39,7 +39,7 @@ use rhai::Dynamic; #[test] - + fn test_empty_array() { let arr: Vec = vec![]; let result = if arr.is_empty() { 0.0 } else { arr.iter().sum::() / arr.len() as f64 }; diff --git a/tests/unit/basic/basic_keywords_math_basic_math.rs b/tests/unit/basic/basic_keywords_math_basic_math.rs index 4c7de21..4df62ee 100644 --- a/tests/unit/basic/basic_keywords_math_basic_math.rs +++ b/tests/unit/basic/basic_keywords_math_basic_math.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/math/basic_math.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -9,7 +9,7 @@ #[test] - + fn test_int() { assert_eq!(3.9_f64.trunc() as i64, 3); assert_eq!((-3.9_f64).trunc() as i64, -3); @@ -17,7 +17,7 @@ #[test] - + fn test_floor_ceil() { assert_eq!(3.7_f64.floor() as i64, 3); assert_eq!(3.2_f64.ceil() as i64, 4); @@ -25,7 +25,7 @@ #[test] - + fn test_minmax() { assert_eq!(10_i64.max(5), 10); assert_eq!(10_i64.min(5), 5); @@ -33,14 +33,14 @@ #[test] - + fn test_mod() { assert_eq!(17 % 5, 2); } #[test] - + fn test_sgn() { assert_eq!((-5_i64).signum(), -1); assert_eq!(5_i64.signum(), 1); @@ -49,14 +49,14 @@ #[test] - + fn test_sqrt() { assert!((16_f64.sqrt() - 4.0).abs() < 0.0001); } #[test] - + fn test_pow() { assert!((2_f64.powf(8.0) - 256.0).abs() < 0.0001); } \ No newline at end of file diff --git a/tests/unit/basic/basic_keywords_math_minmax.rs b/tests/unit/basic/basic_keywords_math_minmax.rs index 142954d..07eed94 100644 --- a/tests/unit/basic/basic_keywords_math_minmax.rs +++ b/tests/unit/basic/basic_keywords_math_minmax.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/math/minmax.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -9,7 +9,7 @@ #[test] - + fn test_max_values() { assert_eq!(10_i64.max(5), 10); assert_eq!(3.5_f64.max(7.2), 7.2); @@ -17,7 +17,7 @@ #[test] - + fn test_min_values() { assert_eq!(10_i64.min(5), 5); assert_eq!(3.5_f64.min(7.2), 3.5); diff --git a/tests/unit/basic/basic_keywords_math_random.rs b/tests/unit/basic/basic_keywords_math_random.rs index 55303b8..e603edf 100644 --- a/tests/unit/basic/basic_keywords_math_random.rs +++ b/tests/unit/basic/basic_keywords_math_random.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/math/random.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -9,7 +9,7 @@ #[test] - + fn test_mod() { assert_eq!(17 % 5, 2); assert_eq!(10 % 3, 1); diff --git a/tests/unit/basic/basic_keywords_math_round.rs b/tests/unit/basic/basic_keywords_math_round.rs index c26617e..81cbe2d 100644 --- a/tests/unit/basic/basic_keywords_math_round.rs +++ b/tests/unit/basic/basic_keywords_math_round.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/math/round.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -9,7 +9,7 @@ #[test] - + fn test_round_basic() { assert_eq!(3.7_f64.round() as i64, 4); assert_eq!(3.2_f64.round() as i64, 3); @@ -18,7 +18,7 @@ #[test] - + fn test_round_decimals() { let n = 2.71828_f64; let decimals = 2; diff --git a/tests/unit/basic/basic_keywords_math_trig.rs b/tests/unit/basic/basic_keywords_math_trig.rs index 8a184c5..b16eb73 100644 --- a/tests/unit/basic/basic_keywords_math_trig.rs +++ b/tests/unit/basic/basic_keywords_math_trig.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/math/trig.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -9,35 +9,35 @@ #[test] - + fn test_sin() { assert!((0.0_f64.sin() - 0.0).abs() < 0.0001); } #[test] - + fn test_cos() { assert!((0.0_f64.cos() - 1.0).abs() < 0.0001); } #[test] - + fn test_log() { assert!((100.0_f64.log10() - 2.0).abs() < 0.0001); } #[test] - + fn test_exp() { assert!((0.0_f64.exp() - 1.0).abs() < 0.0001); } #[test] - + fn test_pi() { assert!(std::f64::consts::PI > 3.14); assert!(std::f64::consts::PI < 3.15); diff --git a/tests/unit/basic/basic_keywords_mcp_directory.rs b/tests/unit/basic/basic_keywords_mcp_directory.rs index 5a87581..4838083 100644 --- a/tests/unit/basic/basic_keywords_mcp_directory.rs +++ b/tests/unit/basic/basic_keywords_mcp_directory.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/mcp_directory.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_parse_csv_columns() { let loader = McpCsvLoader::new("./work", "test"); @@ -24,7 +24,7 @@ #[test] - + fn test_parse_args() { let loader = McpCsvLoader::new("./work", "test"); @@ -37,7 +37,7 @@ #[test] - + fn test_infer_server_type() { let loader = McpCsvLoader::new("./work", "test"); diff --git a/tests/unit/basic/basic_keywords_messaging_send_template.rs b/tests/unit/basic/basic_keywords_messaging_send_template.rs index 3aa0308..04e7e2b 100644 --- a/tests/unit/basic/basic_keywords_messaging_send_template.rs +++ b/tests/unit/basic/basic_keywords_messaging_send_template.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/messaging/send_template.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use rhai::Dynamic; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_send_template_valid_email() { let result = send_template_message("welcome", "user@example.com", "email", None); assert!(result.get("success").unwrap().as_bool().unwrap()); @@ -19,7 +19,7 @@ use rhai::Dynamic; #[test] - + fn test_send_template_invalid_email() { let result = send_template_message("welcome", "invalid-email", "email", None); assert!(!result.get("success").unwrap().as_bool().unwrap()); @@ -27,7 +27,7 @@ use rhai::Dynamic; #[test] - + fn test_send_template_invalid_channel() { let result = send_template_message("welcome", "user@example.com", "invalid", None); assert!(!result.get("success").unwrap().as_bool().unwrap()); @@ -35,7 +35,7 @@ use rhai::Dynamic; #[test] - + fn test_send_template_batch() { let mut recipients = Array::new(); recipients.push(Dynamic::from("user1@example.com")); @@ -48,7 +48,7 @@ use rhai::Dynamic; #[test] - + fn test_create_template() { let result = create_message_template("test", "email", Some("Subject"), "Hello {{name}}!"); assert!(result.get("success").unwrap().as_bool().unwrap()); @@ -56,7 +56,7 @@ use rhai::Dynamic; #[test] - + fn test_create_template_empty_name() { let result = create_message_template("", "email", None, "Content"); assert!(!result.get("success").unwrap().as_bool().unwrap()); @@ -64,7 +64,7 @@ use rhai::Dynamic; #[test] - + fn test_extract_template_variables() { let content = "Hello {{name}}, your order {{order_id}} is ready!"; let vars = extract_template_variables(content); @@ -73,7 +73,7 @@ use rhai::Dynamic; #[test] - + fn test_extract_template_variables_empty() { let content = "Hello, no variables here!"; let vars = extract_template_variables(content); @@ -82,7 +82,7 @@ use rhai::Dynamic; #[test] - + fn test_generate_message_id() { let id = generate_message_id(); assert!(id.starts_with("msg_")); diff --git a/tests/unit/basic/basic_keywords_model_routing.rs b/tests/unit/basic/basic_keywords_model_routing.rs index 7d2e837..53b4f45 100644 --- a/tests/unit/basic/basic_keywords_model_routing.rs +++ b/tests/unit/basic/basic_keywords_model_routing.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/model_routing.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_model_router_new() { let router = ModelRouter::new(); assert_eq!(router.default_model, "default"); @@ -18,7 +18,7 @@ #[test] - + fn test_auto_routing_code() { let mut router = ModelRouter::new(); router.models.insert( @@ -40,7 +40,7 @@ #[test] - + fn test_auto_routing_quality() { let mut router = ModelRouter::new(); router.models.insert( @@ -63,7 +63,7 @@ #[test] - + fn test_auto_routing_fast() { let mut router = ModelRouter::new(); router.models.insert( @@ -85,7 +85,7 @@ #[test] - + fn test_routing_strategy_default() { let strategy = RoutingStrategy::default(); assert_eq!(strategy, RoutingStrategy::Manual); diff --git a/tests/unit/basic/basic_keywords_on_change.rs b/tests/unit/basic/basic_keywords_on_change.rs index 77fb89e..a757ac5 100644 --- a/tests/unit/basic/basic_keywords_on_change.rs +++ b/tests/unit/basic/basic_keywords_on_change.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/on_change.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_parse_folder_path_account() { let (provider, email, path) = parse_folder_path("account://user@gmail.com/Documents/invoices"); @@ -19,7 +19,7 @@ #[test] - + fn test_parse_folder_path_gdrive() { let (provider, email, path) = parse_folder_path("gdrive:///shared/reports"); assert_eq!(provider, FolderProvider::GDrive); @@ -29,7 +29,7 @@ #[test] - + fn test_parse_folder_path_onedrive() { let (provider, email, path) = parse_folder_path("onedrive:///business/docs"); assert_eq!(provider, FolderProvider::OneDrive); @@ -39,7 +39,7 @@ #[test] - + fn test_parse_folder_path_dropbox() { let (provider, email, path) = parse_folder_path("dropbox:///team/assets"); assert_eq!(provider, FolderProvider::Dropbox); @@ -49,7 +49,7 @@ #[test] - + fn test_parse_folder_path_local() { let (provider, email, path) = parse_folder_path("/home/user/documents"); assert_eq!(provider, FolderProvider::Local); @@ -59,7 +59,7 @@ #[test] - + fn test_is_cloud_path() { assert!(is_cloud_path("account://user@gmail.com/docs")); assert!(is_cloud_path("gdrive:///shared")); @@ -71,7 +71,7 @@ #[test] - + fn test_folder_provider_from_str() { assert_eq!( FolderProvider::from_str("gdrive"), @@ -114,7 +114,7 @@ #[test] - + fn test_change_event_type_from_str() { assert_eq!( ChangeEventType::from_str("create"), @@ -153,7 +153,7 @@ #[test] - + fn test_sanitize_path() { assert_eq!( sanitize_path_for_filename("/home/user/docs"), @@ -171,7 +171,7 @@ #[test] - + fn test_folder_monitor_struct() { let monitor = FolderMonitor { id: Uuid::new_v4(), @@ -194,7 +194,7 @@ #[test] - + fn test_folder_change_event_struct() { let event = FolderChangeEvent { id: Uuid::new_v4(), @@ -214,7 +214,7 @@ #[test] - + fn test_detect_provider_from_email() { assert_eq!( detect_provider_from_email("user@gmail.com"), diff --git a/tests/unit/basic/basic_keywords_on_email.rs b/tests/unit/basic/basic_keywords_on_email.rs index 596c0ce..8837f4c 100644 --- a/tests/unit/basic/basic_keywords_on_email.rs +++ b/tests/unit/basic/basic_keywords_on_email.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/on_email.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_email_monitor_struct() { let monitor = EmailMonitor { id: Uuid::new_v4(), @@ -28,7 +28,7 @@ #[test] - + fn test_email_monitor_with_filters() { let monitor = EmailMonitor { id: Uuid::new_v4(), @@ -47,7 +47,7 @@ #[test] - + fn test_email_attachment_struct() { let attachment = EmailAttachment { filename: "document.pdf".to_string(), @@ -62,7 +62,7 @@ #[test] - + fn test_email_received_event_struct() { let event = EmailReceivedEvent { id: Uuid::new_v4(), @@ -89,7 +89,7 @@ #[test] - + fn test_parse_email_path_basic() { let result = parse_email_path("email://user@gmail.com"); assert!(result.is_some()); @@ -100,7 +100,7 @@ #[test] - + fn test_parse_email_path_with_folder() { let result = parse_email_path("email://user@gmail.com/INBOX"); assert!(result.is_some()); @@ -111,7 +111,7 @@ #[test] - + fn test_parse_email_path_invalid() { assert!(parse_email_path("user@gmail.com").is_none()); assert!(parse_email_path("mailto:user@gmail.com").is_none()); @@ -120,7 +120,7 @@ #[test] - + fn test_is_email_path() { assert!(is_email_path("email://user@gmail.com")); assert!(is_email_path("email://user@company.com/INBOX")); @@ -131,7 +131,7 @@ #[test] - + fn test_sanitize_email_for_filename() { assert_eq!( sanitize_email_for_filename("user@gmail.com"), @@ -149,7 +149,7 @@ #[test] - + fn test_email_event_without_attachments() { let event = EmailReceivedEvent { id: Uuid::new_v4(), @@ -170,7 +170,7 @@ #[test] - + fn test_multiple_to_addresses() { let event = EmailReceivedEvent { id: Uuid::new_v4(), @@ -196,7 +196,7 @@ #[test] - + fn test_multiple_attachments() { let attachments = vec![ EmailAttachment { diff --git a/tests/unit/basic/basic_keywords_play.rs b/tests/unit/basic/basic_keywords_play.rs index c10ff9d..8e71c9a 100644 --- a/tests/unit/basic/basic_keywords_play.rs +++ b/tests/unit/basic/basic_keywords_play.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/play.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_content_type_from_extension() { assert_eq!(ContentType::from_extension("mp4"), ContentType::Video); assert_eq!(ContentType::from_extension("MP3"), ContentType::Audio); @@ -28,7 +28,7 @@ #[test] - + fn test_content_type_from_mime() { assert_eq!(ContentType::from_mime("video/mp4"), ContentType::Video); assert_eq!(ContentType::from_mime("audio/mpeg"), ContentType::Audio); @@ -38,7 +38,7 @@ #[test] - + fn test_play_options_from_string() { let opts = PlayOptions::from_string("autoplay,loop,muted"); assert!(opts.autoplay); @@ -61,7 +61,7 @@ #[test] - + fn test_detect_content_type() { assert_eq!( detect_content_type("https://youtube.com/watch?v=123"), @@ -85,7 +85,7 @@ #[test] - + fn test_extract_title_from_source() { assert_eq!(extract_title_from_source("documents/report.pdf"), "report"); assert_eq!( @@ -100,7 +100,7 @@ #[test] - + fn test_player_component() { assert_eq!(ContentType::Video.player_component(), "video-player"); assert_eq!(ContentType::Audio.player_component(), "audio-player"); diff --git a/tests/unit/basic/basic_keywords_procedures.rs b/tests/unit/basic/basic_keywords_procedures.rs index 8f63c8f..d460797 100644 --- a/tests/unit/basic/basic_keywords_procedures.rs +++ b/tests/unit/basic/basic_keywords_procedures.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/procedures.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,7 +7,7 @@ use rhai::Dynamic; -// Original: use super::*; - tests used internal functions from botserver + fn setup() { clear_procedures(); @@ -15,7 +15,7 @@ use rhai::Dynamic; #[test] - + fn test_preprocess_sub() { setup(); @@ -29,13 +29,13 @@ y = 2 let result = preprocess_subs(input); - // SUB should be extracted + assert!(!result.contains("SUB MySub")); assert!(!result.contains("END SUB")); assert!(result.contains("x = 1")); assert!(result.contains("y = 2")); - // Procedure should be registered + assert!(has_procedure("MYSUB")); let proc = get_procedure("MYSUB").unwrap(); assert_eq!(proc.params.len(), 2); @@ -44,7 +44,7 @@ y = 2 #[test] - + fn test_preprocess_function() { setup(); @@ -57,12 +57,12 @@ result = Add(1, 2) let result = preprocess_functions(input); - // FUNCTION should be extracted + assert!(!result.contains("FUNCTION Add")); assert!(!result.contains("END FUNCTION")); assert!(result.contains("result = Add(1, 2)")); - // Procedure should be registered + assert!(has_procedure("ADD")); let proc = get_procedure("ADD").unwrap(); assert!(proc.is_function); @@ -70,7 +70,7 @@ result = Add(1, 2) #[test] - + fn test_preprocess_sub_no_params() { setup(); @@ -89,11 +89,11 @@ END SUB #[test] - + fn test_preprocess_call() { setup(); - // First register a SUB + let sub_input = r#" SUB Greet(name) TALK "Hello " + name @@ -101,18 +101,18 @@ END SUB "#; preprocess_subs(sub_input); - // Then preprocess CALL + let call_input = "CALL Greet(\"World\")"; let result = preprocess_calls(call_input); - // Should contain parameter assignment and body + assert!(result.contains("let name = \"World\"")); assert!(result.contains("TALK \"Hello \" + name")); } #[test] - + fn test_eval_bool_condition() { assert!(eval_bool_condition(&Dynamic::from(true))); assert!(!eval_bool_condition(&Dynamic::from(false))); @@ -128,7 +128,7 @@ END SUB #[test] - + fn test_clear_procedures() { setup(); @@ -144,7 +144,7 @@ END SUB #[test] - + fn test_full_pipeline() { setup(); @@ -165,17 +165,17 @@ total = Calculate(5, 3) let result = preprocess_procedures(input); - // Should have inlined the CALL + assert!(result.contains("let name = \"User\"")); assert!(result.contains("let greeting = \"Hello\"")); - // Original definitions should be gone + assert!(!result.contains("SUB SendGreeting")); assert!(!result.contains("END SUB")); assert!(!result.contains("FUNCTION Calculate")); assert!(!result.contains("END FUNCTION")); - // Both should be registered + assert!(has_procedure("SENDGREETING")); assert!(has_procedure("CALCULATE")); } \ No newline at end of file diff --git a/tests/unit/basic/basic_keywords_qrcode.rs b/tests/unit/basic/basic_keywords_qrcode.rs index 985d23e..5c4d8e9 100644 --- a/tests/unit/basic/basic_keywords_qrcode.rs +++ b/tests/unit/basic/basic_keywords_qrcode.rs @@ -1,24 +1,24 @@ -//! Unit tests migrated from src/basic/keywords/qrcode.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_qr_code_generation() { - // Create a mock state and user for testing - // In real tests, you'd set up proper test fixtures + + let result = QrCode::new(b"https://example.com"); assert!(result.is_ok()); } #[test] - + fn test_qr_code_with_unicode() { let result = QrCode::new("Hello 世界 🌍".as_bytes()); assert!(result.is_ok()); @@ -26,7 +26,7 @@ #[test] - + fn test_qr_code_long_data() { let long_data = "A".repeat(1000); let result = QrCode::new(long_data.as_bytes()); @@ -35,7 +35,7 @@ #[test] - + fn test_qr_code_url() { let url = "https://example.com/path?param=value&other=123"; let result = QrCode::new(url.as_bytes()); @@ -44,7 +44,7 @@ #[test] - + fn test_qr_code_json() { let json = r#"{"id": 123, "name": "Test", "active": true}"#; let result = QrCode::new(json.as_bytes()); diff --git a/tests/unit/basic/basic_keywords_remember.rs b/tests/unit/basic/basic_keywords_remember.rs index 876fa20..70fe00d 100644 --- a/tests/unit/basic/basic_keywords_remember.rs +++ b/tests/unit/basic/basic_keywords_remember.rs @@ -1,16 +1,16 @@ -//! Unit tests migrated from src/basic/keywords/remember.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_parse_duration() { - // Test various duration formats + assert!(parse_duration("30 days").is_ok()); assert!(parse_duration("1 hour").is_ok()); assert!(parse_duration("forever").is_ok()); diff --git a/tests/unit/basic/basic_keywords_save_from_unstructured.rs b/tests/unit/basic/basic_keywords_save_from_unstructured.rs index b6a357a..0e4e150 100644 --- a/tests/unit/basic/basic_keywords_save_from_unstructured.rs +++ b/tests/unit/basic/basic_keywords_save_from_unstructured.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/save_from_unstructured.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_clean_value_for_type() { assert_eq!(clean_value_for_type(&json!("test"), "text"), json!("test")); assert_eq!(clean_value_for_type(&json!("42"), "integer"), json!(42)); @@ -18,7 +18,7 @@ #[test] - + fn test_get_default_schema() { let leads_schema = get_default_schema("leads"); assert!(leads_schema.is_array()); diff --git a/tests/unit/basic/basic_keywords_send_mail.rs b/tests/unit/basic/basic_keywords_send_mail.rs index 34ecd1e..e7e4623 100644 --- a/tests/unit/basic/basic_keywords_send_mail.rs +++ b/tests/unit/basic/basic_keywords_send_mail.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/send_mail.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_apply_template_variables() { let template = "Hello {{name}}, your order {{order_id}} is ready!"; let vars = json!({ @@ -23,7 +23,7 @@ #[test] - + fn test_extract_template_subject() { let content = "Subject: Welcome to our service\n\nHello there!"; let subject = extract_template_subject(content); diff --git a/tests/unit/basic/basic_keywords_send_template.rs b/tests/unit/basic/basic_keywords_send_template.rs index 18e8d81..c243b29 100644 --- a/tests/unit/basic/basic_keywords_send_template.rs +++ b/tests/unit/basic/basic_keywords_send_template.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/send_template.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -9,9 +9,9 @@ #[test] - + fn test_module_structure() { - // This test verifies the module compiles correctly - // Actual function tests are in the messaging/send_template.rs module + + assert!(true); } \ No newline at end of file diff --git a/tests/unit/basic/basic_keywords_set_schedule.rs b/tests/unit/basic/basic_keywords_set_schedule.rs index 8254689..ab68627 100644 --- a/tests/unit/basic/basic_keywords_set_schedule.rs +++ b/tests/unit/basic/basic_keywords_set_schedule.rs @@ -1,21 +1,21 @@ -//! Unit tests migrated from src/basic/keywords/set_schedule.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_every_minute() { assert_eq!(parse_natural_schedule("every minute").unwrap(), "* * * * *"); } #[test] - + fn test_every_n_minutes() { assert_eq!( parse_natural_schedule("every 5 minutes").unwrap(), @@ -33,7 +33,7 @@ #[test] - + fn test_every_hour() { assert_eq!(parse_natural_schedule("every hour").unwrap(), "0 * * * *"); assert_eq!(parse_natural_schedule("hourly").unwrap(), "0 * * * *"); @@ -41,7 +41,7 @@ #[test] - + fn test_every_n_hours() { assert_eq!( parse_natural_schedule("every 2 hours").unwrap(), @@ -55,7 +55,7 @@ #[test] - + fn test_every_day() { assert_eq!(parse_natural_schedule("every day").unwrap(), "0 0 * * *"); assert_eq!(parse_natural_schedule("daily").unwrap(), "0 0 * * *"); @@ -63,7 +63,7 @@ #[test] - + fn test_every_week() { assert_eq!(parse_natural_schedule("every week").unwrap(), "0 0 * * 0"); assert_eq!(parse_natural_schedule("weekly").unwrap(), "0 0 * * 0"); @@ -71,7 +71,7 @@ #[test] - + fn test_every_month() { assert_eq!(parse_natural_schedule("every month").unwrap(), "0 0 1 * *"); assert_eq!(parse_natural_schedule("monthly").unwrap(), "0 0 1 * *"); @@ -79,7 +79,7 @@ #[test] - + fn test_at_time() { assert_eq!(parse_natural_schedule("at 9am").unwrap(), "0 9 * * *"); assert_eq!(parse_natural_schedule("at 9:30am").unwrap(), "30 9 * * *"); @@ -91,7 +91,7 @@ #[test] - + fn test_day_of_week() { assert_eq!(parse_natural_schedule("every monday").unwrap(), "0 0 * * 1"); assert_eq!(parse_natural_schedule("every friday").unwrap(), "0 0 * * 5"); @@ -100,7 +100,7 @@ #[test] - + fn test_day_with_time() { assert_eq!( parse_natural_schedule("every monday at 9am").unwrap(), @@ -114,7 +114,7 @@ #[test] - + fn test_weekdays() { assert_eq!(parse_natural_schedule("weekdays").unwrap(), "0 0 * * 1-5"); assert_eq!( @@ -129,7 +129,7 @@ #[test] - + fn test_weekends() { assert_eq!(parse_natural_schedule("weekends").unwrap(), "0 0 * * 0,6"); assert_eq!( @@ -140,7 +140,7 @@ #[test] - + fn test_combined() { assert_eq!( parse_natural_schedule("every day at 9am").unwrap(), @@ -154,7 +154,7 @@ #[test] - + fn test_hour_range() { assert_eq!( parse_natural_schedule("every hour from 9 to 17").unwrap(), @@ -164,7 +164,7 @@ #[test] - + fn test_business_hours() { assert_eq!( parse_natural_schedule("business hours").unwrap(), @@ -182,7 +182,7 @@ #[test] - + fn test_raw_cron_passthrough() { assert_eq!(parse_natural_schedule("0 * * * *").unwrap(), "0 * * * *"); assert_eq!( @@ -197,8 +197,8 @@ #[test] - + fn test_invalid_input() { assert!(parse_natural_schedule("potato salad").is_err()); - assert!(parse_natural_schedule("every 100 minutes").is_err()); // > 59 + assert!(parse_natural_schedule("every 100 minutes").is_err()); } \ No newline at end of file diff --git a/tests/unit/basic/basic_keywords_sms.rs b/tests/unit/basic/basic_keywords_sms.rs index 0f29bea..65e0406 100644 --- a/tests/unit/basic/basic_keywords_sms.rs +++ b/tests/unit/basic/basic_keywords_sms.rs @@ -1,49 +1,49 @@ -//! Unit tests migrated from src/basic/keywords/sms.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_normalize_phone_us_10_digit() { assert_eq!(normalize_phone_number("5551234567"), "+15551234567"); } #[test] - + fn test_normalize_phone_us_11_digit() { assert_eq!(normalize_phone_number("15551234567"), "+15551234567"); } #[test] - + fn test_normalize_phone_with_plus() { assert_eq!(normalize_phone_number("+15551234567"), "+15551234567"); } #[test] - + fn test_normalize_phone_with_formatting() { assert_eq!(normalize_phone_number("+1 (555) 123-4567"), "+15551234567"); } #[test] - + fn test_normalize_phone_international() { assert_eq!(normalize_phone_number("+44 7911 123456"), "+447911123456"); } #[test] - + fn test_sms_provider_from_str() { assert_eq!(SmsProvider::from("twilio"), SmsProvider::Twilio); assert_eq!(SmsProvider::from("aws_sns"), SmsProvider::AwsSns); diff --git a/tests/unit/basic/basic_keywords_social_get_metrics.rs b/tests/unit/basic/basic_keywords_social_get_metrics.rs index be5dbe9..a0a4308 100644 --- a/tests/unit/basic/basic_keywords_social_get_metrics.rs +++ b/tests/unit/basic/basic_keywords_social_get_metrics.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/social/get_metrics.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_engagement_to_dynamic() { let engagement = PostEngagement { likes: 100, diff --git a/tests/unit/basic/basic_keywords_social_media.rs b/tests/unit/basic/basic_keywords_social_media.rs index d32d80d..c243b29 100644 --- a/tests/unit/basic/basic_keywords_social_media.rs +++ b/tests/unit/basic/basic_keywords_social_media.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/social_media.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -9,9 +9,9 @@ #[test] - + fn test_module_structure() { - // This test verifies the module compiles correctly - // Actual function tests are in the social/ module files + + assert!(true); } \ No newline at end of file diff --git a/tests/unit/basic/basic_keywords_social_post_to_scheduled.rs b/tests/unit/basic/basic_keywords_social_post_to_scheduled.rs index 1891491..fb63644 100644 --- a/tests/unit/basic/basic_keywords_social_post_to_scheduled.rs +++ b/tests/unit/basic/basic_keywords_social_post_to_scheduled.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/social/post_to_scheduled.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_parse_schedule_time() { let result = parse_schedule_time("2025-02-01 10:00"); assert!(result.is_ok()); diff --git a/tests/unit/basic/basic_keywords_string_functions.rs b/tests/unit/basic/basic_keywords_string_functions.rs index 53e5c2c..42095c4 100644 --- a/tests/unit/basic/basic_keywords_string_functions.rs +++ b/tests/unit/basic/basic_keywords_string_functions.rs @@ -1,11 +1,11 @@ -//! Unit tests migrated from src/basic/keywords/string_functions.rs -//! These tests were originally in botserver and have been migrated to bottest. + + use botserver::basic::keywords::string_functions::{instr_impl, is_numeric_impl}; #[test] - + fn test_instr_basic() { assert_eq!(instr_impl(1, "Hello, World!", "World"), 8); assert_eq!(instr_impl(1, "Hello, World!", "o"), 5); @@ -14,7 +14,7 @@ use botserver::basic::keywords::string_functions::{instr_impl, is_numeric_impl}; #[test] - + fn test_instr_with_start() { assert_eq!(instr_impl(1, "one two one", "one"), 1); assert_eq!(instr_impl(2, "one two one", "one"), 9); @@ -23,7 +23,7 @@ use botserver::basic::keywords::string_functions::{instr_impl, is_numeric_impl}; #[test] - + fn test_instr_edge_cases() { assert_eq!(instr_impl(1, "", "test"), 0); assert_eq!(instr_impl(1, "test", ""), 0); @@ -32,7 +32,7 @@ use botserver::basic::keywords::string_functions::{instr_impl, is_numeric_impl}; #[test] - + fn test_is_numeric_integers() { assert!(is_numeric_impl("42")); assert!(is_numeric_impl("-17")); @@ -42,7 +42,7 @@ use botserver::basic::keywords::string_functions::{instr_impl, is_numeric_impl}; #[test] - + fn test_is_numeric_decimals() { assert!(is_numeric_impl("3.14")); assert!(is_numeric_impl("-0.5")); @@ -52,7 +52,7 @@ use botserver::basic::keywords::string_functions::{instr_impl, is_numeric_impl}; #[test] - + fn test_is_numeric_scientific() { assert!(is_numeric_impl("1e10")); assert!(is_numeric_impl("2.5E-3")); @@ -61,7 +61,7 @@ use botserver::basic::keywords::string_functions::{instr_impl, is_numeric_impl}; #[test] - + fn test_is_numeric_invalid() { assert!(!is_numeric_impl("")); assert!(!is_numeric_impl("abc")); diff --git a/tests/unit/basic/basic_keywords_switch_case.rs b/tests/unit/basic/basic_keywords_switch_case.rs index be08f95..c6daa61 100644 --- a/tests/unit/basic/basic_keywords_switch_case.rs +++ b/tests/unit/basic/basic_keywords_switch_case.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/switch_case.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use rhai::Dynamic; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_switch_match_strings() { let a = Dynamic::from("hello"); let b = Dynamic::from("hello"); @@ -23,7 +23,7 @@ use rhai::Dynamic; #[test] - + fn test_switch_match_integers() { let a = Dynamic::from(42_i64); let b = Dynamic::from(42_i64); @@ -35,7 +35,7 @@ use rhai::Dynamic; #[test] - + fn test_switch_match_floats() { let a = Dynamic::from(3.14_f64); let b = Dynamic::from(3.14_f64); @@ -47,7 +47,7 @@ use rhai::Dynamic; #[test] - + fn test_switch_match_mixed_numeric() { let int_val = Dynamic::from(42_i64); let float_val = Dynamic::from(42.0_f64); @@ -57,7 +57,7 @@ use rhai::Dynamic; #[test] - + fn test_preprocess_simple_switch() { let input = r#" SWITCH role @@ -77,7 +77,7 @@ END SWITCH #[test] - + fn test_preprocess_multiple_values() { let input = r#" SWITCH day diff --git a/tests/unit/basic/basic_keywords_table_definition.rs b/tests/unit/basic/basic_keywords_table_definition.rs index 8776a69..7a7b332 100644 --- a/tests/unit/basic/basic_keywords_table_definition.rs +++ b/tests/unit/basic/basic_keywords_table_definition.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/table_definition.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_parse_table_definition() { let source = r#" TABLE Contacts ON maria @@ -38,7 +38,7 @@ END TABLE #[test] - + fn test_parse_field_with_precision() { let field = parse_field_definition("Preco double(10,2)", 0).unwrap(); assert_eq!(field.name, "Preco"); @@ -49,7 +49,7 @@ END TABLE #[test] - + fn test_generate_create_table_sql() { let table = TableDefinition { name: "TestTable".to_string(), @@ -89,7 +89,7 @@ END TABLE #[test] - + fn test_map_types() { let field = FieldDefinition { name: "test".to_string(), @@ -121,7 +121,7 @@ END TABLE #[test] - + fn test_sanitize_identifier() { assert_eq!(sanitize_identifier("valid_name"), "valid_name"); assert_eq!(sanitize_identifier("DROP TABLE; --"), "DROPTABLE"); @@ -130,7 +130,7 @@ END TABLE #[test] - + fn test_build_connection_string() { let conn = ExternalConnection { name: "test".to_string(), diff --git a/tests/unit/basic/basic_keywords_transfer_to_human.rs b/tests/unit/basic/basic_keywords_transfer_to_human.rs index 48b0de6..f3fb583 100644 --- a/tests/unit/basic/basic_keywords_transfer_to_human.rs +++ b/tests/unit/basic/basic_keywords_transfer_to_human.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/transfer_to_human.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_priority_to_int() { assert_eq!(priority_to_int(Some("urgent")), 3); assert_eq!(priority_to_int(Some("high")), 2); @@ -19,7 +19,7 @@ #[test] - + fn test_find_attendant_by_name() { let attendants = vec![ Attendant { @@ -42,22 +42,22 @@ }, ]; - // Find by exact name + let found = find_attendant(&attendants, Some("John Smith"), None); assert!(found.is_some()); assert_eq!(found.unwrap().id, "att-001"); - // Find by partial name + let found = find_attendant(&attendants, Some("john"), None); assert!(found.is_some()); assert_eq!(found.unwrap().id, "att-001"); - // Find by alias + let found = find_attendant(&attendants, Some("johnny"), None); assert!(found.is_some()); assert_eq!(found.unwrap().id, "att-001"); - // Find by department + let found = find_attendant(&attendants, None, Some("customer-service")); assert!(found.is_some()); assert_eq!(found.unwrap().id, "att-002"); @@ -65,7 +65,7 @@ #[test] - + fn test_transfer_result_to_dynamic() { let result = TransferResult { success: true, diff --git a/tests/unit/basic/basic_keywords_use_account.rs b/tests/unit/basic/basic_keywords_use_account.rs index 0b68158..b95025a 100644 --- a/tests/unit/basic/basic_keywords_use_account.rs +++ b/tests/unit/basic/basic_keywords_use_account.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/use_account.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_parse_account_path() { let result = parse_account_path("account://user@gmail.com/Documents/file.pdf"); assert!(result.is_some()); @@ -19,7 +19,7 @@ #[test] - + fn test_parse_account_path_invalid() { assert!(parse_account_path("local/file.pdf").is_none()); assert!(parse_account_path("/absolute/path").is_none()); @@ -27,7 +27,7 @@ #[test] - + fn test_is_account_path() { assert!(is_account_path("account://user@gmail.com/file.pdf")); assert!(!is_account_path("local/file.pdf")); diff --git a/tests/unit/basic/basic_keywords_use_kb.rs b/tests/unit/basic/basic_keywords_use_kb.rs index c69d77a..a6d2bea 100644 --- a/tests/unit/basic/basic_keywords_use_kb.rs +++ b/tests/unit/basic/basic_keywords_use_kb.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/use_kb.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -8,15 +8,15 @@ use rhai::Dynamic; use rhai::Engine; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_use_kb_syntax() { let mut engine = Engine::new(); - // This would normally use real state and session - // For now just test that the syntax can be registered + + assert!(engine .register_custom_syntax(&["USE_KB", "$expr$"], true, |_, _| Ok(Dynamic::UNIT)) .is_ok()); diff --git a/tests/unit/basic/basic_keywords_use_website.rs b/tests/unit/basic/basic_keywords_use_website.rs index c7099b2..e6bb25b 100644 --- a/tests/unit/basic/basic_keywords_use_website.rs +++ b/tests/unit/basic/basic_keywords_use_website.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/use_website.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -8,11 +8,11 @@ use rhai::Dynamic; use rhai::Engine; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_url_sanitization() { assert_eq!( sanitize_url_for_collection("https://docs.example.com/path"), @@ -26,16 +26,16 @@ use rhai::Engine; #[test] - + fn test_use_website_syntax() { let mut engine = Engine::new(); - // Test USE_WEBSITE with argument + assert!(engine .register_custom_syntax(&["USE_WEBSITE", "$expr$"], true, |_, _| Ok(Dynamic::UNIT)) .is_ok()); - // Test CLEAR_WEBSITES without argument + assert!(engine .register_custom_syntax(&["CLEAR_WEBSITES"], true, |_, _| Ok(Dynamic::UNIT)) .is_ok()); diff --git a/tests/unit/basic/basic_keywords_user_memory.rs b/tests/unit/basic/basic_keywords_user_memory.rs index 0a0fe48..9908db3 100644 --- a/tests/unit/basic/basic_keywords_user_memory.rs +++ b/tests/unit/basic/basic_keywords_user_memory.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/user_memory.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_fact_key_generation() { let fact_key = format!("fact_{}", Uuid::new_v4()); assert!(fact_key.starts_with("fact_")); diff --git a/tests/unit/basic/basic_keywords_validation_isempty.rs b/tests/unit/basic/basic_keywords_validation_isempty.rs index 89d13a4..4766e33 100644 --- a/tests/unit/basic/basic_keywords_validation_isempty.rs +++ b/tests/unit/basic/basic_keywords_validation_isempty.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/validation/isempty.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,12 +7,12 @@ use rhai::Dynamic; -// Original: use super::*; - tests used internal functions from botserver + use rhai::{Array, Map}; #[test] - + fn test_empty_string() { let value = Dynamic::from(""); assert!(check_empty(&value)); @@ -20,7 +20,7 @@ use rhai::Dynamic; #[test] - + fn test_non_empty_string() { let value = Dynamic::from("hello"); assert!(!check_empty(&value)); @@ -28,7 +28,7 @@ use rhai::Dynamic; #[test] - + fn test_empty_array() { let value = Dynamic::from(Array::new()); assert!(check_empty(&value)); @@ -36,7 +36,7 @@ use rhai::Dynamic; #[test] - + fn test_non_empty_array() { let mut arr = Array::new(); arr.push(Dynamic::from(1)); @@ -46,7 +46,7 @@ use rhai::Dynamic; #[test] - + fn test_empty_map() { let value = Dynamic::from(Map::new()); assert!(check_empty(&value)); @@ -54,7 +54,7 @@ use rhai::Dynamic; #[test] - + fn test_unit() { let value = Dynamic::UNIT; assert!(check_empty(&value)); @@ -62,7 +62,7 @@ use rhai::Dynamic; #[test] - + fn test_number_not_empty() { let value = Dynamic::from(0); assert!(!check_empty(&value)); @@ -70,7 +70,7 @@ use rhai::Dynamic; #[test] - + fn test_bool_not_empty() { let value = Dynamic::from(false); assert!(!check_empty(&value)); diff --git a/tests/unit/basic/basic_keywords_validation_isnull.rs b/tests/unit/basic/basic_keywords_validation_isnull.rs index 5b9b233..3d7a282 100644 --- a/tests/unit/basic/basic_keywords_validation_isnull.rs +++ b/tests/unit/basic/basic_keywords_validation_isnull.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/validation/isnull.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -12,7 +12,7 @@ use rhai::Dynamic; #[test] - + fn test_isnull_unit() { use rhai::Dynamic; let value = Dynamic::UNIT; @@ -21,7 +21,7 @@ use rhai::Dynamic; #[test] - + fn test_isnull_not_unit() { use rhai::Dynamic; let value = Dynamic::from("test"); @@ -30,7 +30,7 @@ use rhai::Dynamic; #[test] - + fn test_isnull_number() { use rhai::Dynamic; let value = Dynamic::from(42); diff --git a/tests/unit/basic/basic_keywords_validation_nvl_iif.rs b/tests/unit/basic/basic_keywords_validation_nvl_iif.rs index cfca1e9..3bd1e5d 100644 --- a/tests/unit/basic/basic_keywords_validation_nvl_iif.rs +++ b/tests/unit/basic/basic_keywords_validation_nvl_iif.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/validation/nvl_iif.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -9,7 +9,7 @@ #[test] - + fn test_nvl_logic() { let value = ""; let default = "default"; @@ -19,7 +19,7 @@ #[test] - + fn test_nvl_with_value() { let value = "actual"; let default = "default"; @@ -29,7 +29,7 @@ #[test] - + fn test_iif_true() { let condition = true; let result = if condition { "yes" } else { "no" }; @@ -38,7 +38,7 @@ #[test] - + fn test_iif_false() { let condition = false; let result = if condition { "yes" } else { "no" }; @@ -47,7 +47,7 @@ #[test] - + fn test_choose() { let index = 2; let values = vec!["first", "second", "third"]; diff --git a/tests/unit/basic/basic_keywords_validation_str_val.rs b/tests/unit/basic/basic_keywords_validation_str_val.rs index b06e92e..5eb20de 100644 --- a/tests/unit/basic/basic_keywords_validation_str_val.rs +++ b/tests/unit/basic/basic_keywords_validation_str_val.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/validation/str_val.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -9,7 +9,7 @@ #[test] - + fn test_val_parsing() { assert_eq!("123.45".trim().parse::().unwrap_or(0.0), 123.45); assert_eq!(" 456 ".trim().parse::().unwrap_or(0.0), 456.0); @@ -18,7 +18,7 @@ #[test] - + fn test_cint_rounding() { assert_eq!(2.4_f64.round() as i64, 2); assert_eq!(2.5_f64.round() as i64, 3); diff --git a/tests/unit/basic/basic_keywords_validation_typeof_check.rs b/tests/unit/basic/basic_keywords_validation_typeof_check.rs index 3c6078b..92b8d0c 100644 --- a/tests/unit/basic/basic_keywords_validation_typeof_check.rs +++ b/tests/unit/basic/basic_keywords_validation_typeof_check.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/validation/typeof_check.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use rhai::Dynamic; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_get_type_name() { assert_eq!(get_type_name(&Dynamic::UNIT), "null"); assert_eq!(get_type_name(&Dynamic::from(true)), "boolean"); @@ -22,7 +22,7 @@ use rhai::Dynamic; #[test] - + fn test_is_numeric() { assert!(is_numeric(&Dynamic::from(42_i64))); assert!(is_numeric(&Dynamic::from(3.14_f64))); diff --git a/tests/unit/basic/basic_keywords_weather.rs b/tests/unit/basic/basic_keywords_weather.rs index a435f3f..634ba22 100644 --- a/tests/unit/basic/basic_keywords_weather.rs +++ b/tests/unit/basic/basic_keywords_weather.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/basic/keywords/weather.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_degrees_to_compass() { assert_eq!(degrees_to_compass(0.0), "N"); assert_eq!(degrees_to_compass(45.0), "NE"); @@ -20,7 +20,7 @@ #[test] - + fn test_format_weather_response() { let weather = WeatherData { location: "London".to_string(), diff --git a/tests/unit/basic/basic_keywords_webhook.rs b/tests/unit/basic/basic_keywords_webhook.rs index d8cce6b..ee524eb 100644 --- a/tests/unit/basic/basic_keywords_webhook.rs +++ b/tests/unit/basic/basic_keywords_webhook.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/basic/keywords/webhook.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use rhai::Dynamic; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_webhook_request_to_dynamic() { let mut headers = std::collections::HashMap::new(); headers.insert("Content-Type".to_string(), "application/json".to_string()); @@ -33,7 +33,7 @@ use rhai::Dynamic; #[test] - + fn test_webhook_response_from_dynamic() { let mut map = rhai::Map::new(); map.insert("status".into(), Dynamic::from(201_i64)); @@ -50,7 +50,7 @@ use rhai::Dynamic; #[test] - + fn test_json_to_dynamic_and_back() { let original = json!({ "name": "test", @@ -69,7 +69,7 @@ use rhai::Dynamic; #[test] - + fn test_webhook_response_default() { let response = WebhookResponse::default(); assert_eq!(response.status, 200); @@ -77,7 +77,7 @@ use rhai::Dynamic; #[test] - + fn test_webhook_response_error() { let response = WebhookResponse::error(404, "Not found"); assert_eq!(response.status, 404); diff --git a/tests/unit/basic/mod.rs b/tests/unit/basic/mod.rs index 276c848..6f83578 100644 --- a/tests/unit/basic/mod.rs +++ b/tests/unit/basic/mod.rs @@ -1,4 +1,4 @@ -//! Tests for basic module + mod basic_compiler_goto_transform; mod basic_keywords_a2a_protocol; mod basic_keywords_add_bot; diff --git a/tests/unit/calendar/calendar.rs b/tests/unit/calendar/calendar.rs index ad49ba4..d9afe88 100644 --- a/tests/unit/calendar/calendar.rs +++ b/tests/unit/calendar/calendar.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/calendar/mod.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_event_to_ical_roundtrip() { let event = CalendarEvent { id: Uuid::new_v4(), @@ -32,7 +32,7 @@ #[test] - + fn test_export_import_ical() { let mut engine = CalendarEngine::new(); engine.create_event(CalendarEventInput { diff --git a/tests/unit/calendar/mod.rs b/tests/unit/calendar/mod.rs index 1172ef3..62c6d95 100644 --- a/tests/unit/calendar/mod.rs +++ b/tests/unit/calendar/mod.rs @@ -1,2 +1,2 @@ -//! Tests for calendar module + mod calendar; diff --git a/tests/unit/compliance/compliance.rs b/tests/unit/compliance/compliance.rs index ee518f3..1b5b9db 100644 --- a/tests/unit/compliance/compliance.rs +++ b/tests/unit/compliance/compliance.rs @@ -1,10 +1,10 @@ -//! Unit tests migrated from src/compliance/mod.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[tokio::test] async fn test_compliance_monitor() { @@ -15,7 +15,7 @@ #[test] - + fn test_compliance_score() { let results = vec![ ComplianceCheckResult { diff --git a/tests/unit/compliance/compliance_code_scanner.rs b/tests/unit/compliance/compliance_code_scanner.rs index d5b08ea..9daae22 100644 --- a/tests/unit/compliance/compliance_code_scanner.rs +++ b/tests/unit/compliance/compliance_code_scanner.rs @@ -1,18 +1,18 @@ -//! Unit tests migrated from src/compliance/code_scanner.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_pattern_matching() { let scanner = CodeScanner::new("/tmp/test"); - // Test password detection + let password_pattern = scanner .patterns .iter() @@ -21,7 +21,7 @@ assert!(password_pattern.regex.is_match(r#"password = "secret123""#)); assert!(password_pattern.regex.is_match(r#"PASSWORD = 'mypass'"#)); - // Test underscore keyword detection + let underscore_pattern = scanner .patterns .iter() @@ -33,7 +33,7 @@ #[test] - + fn test_severity_ordering() { assert!(IssueSeverity::Critical > IssueSeverity::High); assert!(IssueSeverity::High > IssueSeverity::Medium); @@ -43,7 +43,7 @@ #[test] - + fn test_stats_merge() { let mut stats1 = ScanStats { critical: 1, @@ -72,7 +72,7 @@ #[test] - + fn test_csv_escape() { assert_eq!(escape_csv("simple"), "simple"); assert_eq!(escape_csv("with,comma"), "\"with,comma\""); @@ -81,7 +81,7 @@ #[test] - + fn test_redact_sensitive() { let scanner = CodeScanner::new("/tmp/test"); diff --git a/tests/unit/compliance/mod.rs b/tests/unit/compliance/mod.rs index 9ea000a..6a48246 100644 --- a/tests/unit/compliance/mod.rs +++ b/tests/unit/compliance/mod.rs @@ -1,3 +1,3 @@ -//! Tests for compliance module + mod compliance_code_scanner; mod compliance; diff --git a/tests/unit/console/console_wizard.rs b/tests/unit/console/console_wizard.rs index 30b500d..94bb7e6 100644 --- a/tests/unit/console/console_wizard.rs +++ b/tests/unit/console/console_wizard.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/console/wizard.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_default_config() { let config = WizardConfig::default(); assert_eq!(config.llm_provider, LlmProvider::None); @@ -17,7 +17,7 @@ #[test] - + fn test_slug_generation() { let mut config = WizardConfig::default(); config.organization.name = "My Test Company".to_string(); diff --git a/tests/unit/console/mod.rs b/tests/unit/console/mod.rs index 77e0dbd..eaa28e8 100644 --- a/tests/unit/console/mod.rs +++ b/tests/unit/console/mod.rs @@ -1,2 +1,2 @@ -//! Tests for console module + mod console_wizard; diff --git a/tests/unit/core/core_bot_manager.rs b/tests/unit/core/core_bot_manager.rs index 341db88..c6e1a7b 100644 --- a/tests/unit/core/core_bot_manager.rs +++ b/tests/unit/core/core_bot_manager.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/core/bot/manager.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_sanitize_bot_name() { let manager = BotManager::new("", "", "", "", PathBuf::new()); @@ -21,7 +21,7 @@ #[test] - + fn test_bot_config_default() { let settings = BotSettings::default(); assert!(settings.knowledge_bases.is_empty()); @@ -30,7 +30,7 @@ #[test] - + fn test_bot_status_display() { assert_eq!(format!("{}", BotStatus::Active), "Active"); assert_eq!(format!("{}", BotStatus::Creating), "Creating"); @@ -38,7 +38,7 @@ #[test] - + fn test_bot_route_from_config() { let config = BotConfig { id: Uuid::new_v4(), diff --git a/tests/unit/core/core_config_model_routing_config.rs b/tests/unit/core/core_config_model_routing_config.rs index 9536160..349e049 100644 --- a/tests/unit/core/core_config_model_routing_config.rs +++ b/tests/unit/core/core_config_model_routing_config.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/core/config/model_routing_config.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_default_config() { let config = ModelRoutingConfig::default(); assert_eq!(config.routing_strategy, RoutingStrategy::Default); @@ -19,7 +19,7 @@ #[test] - + fn test_routing_strategy_from_str() { assert_eq!(RoutingStrategy::from("default"), RoutingStrategy::Default); assert_eq!( @@ -38,7 +38,7 @@ #[test] - + fn test_get_model_for_task_default_strategy() { let config = ModelRoutingConfig::default(); assert_eq!(config.get_model_for_task(TaskType::Simple), "gpt-4o"); @@ -48,7 +48,7 @@ #[test] - + fn test_get_model_for_task_based_strategy() { let config = ModelRoutingConfig { routing_strategy: RoutingStrategy::TaskBased, @@ -61,7 +61,7 @@ #[test] - + fn test_get_fallback_model() { let config = ModelRoutingConfig::default(); assert_eq!(config.get_fallback_model("gpt-4o"), Some("gpt-4o-mini")); @@ -75,7 +75,7 @@ #[test] - + fn test_get_fallback_model_disabled() { let config = ModelRoutingConfig { fallback_enabled: false, @@ -86,7 +86,7 @@ #[test] - + fn test_get_all_models() { let config = ModelRoutingConfig::default(); let models = config.get_all_models(); @@ -97,7 +97,7 @@ #[test] - + fn test_routing_strategy_display() { assert_eq!(format!("{}", RoutingStrategy::Default), "default"); assert_eq!(format!("{}", RoutingStrategy::TaskBased), "task-based"); diff --git a/tests/unit/core/core_config_sse_config.rs b/tests/unit/core/core_config_sse_config.rs index bab98e8..96a839a 100644 --- a/tests/unit/core/core_config_sse_config.rs +++ b/tests/unit/core/core_config_sse_config.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/core/config/sse_config.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_default_config() { let config = SseConfig::default(); assert!(config.enabled); @@ -18,7 +18,7 @@ #[test] - + fn test_can_accept_connection() { let config = SseConfig::default(); assert!(config.can_accept_connection(0)); @@ -29,7 +29,7 @@ #[test] - + fn test_can_accept_connection_disabled() { let config = SseConfig { enabled: false, @@ -40,7 +40,7 @@ #[test] - + fn test_heartbeat_duration() { let config = SseConfig { heartbeat_seconds: 45, diff --git a/tests/unit/core/core_config_user_memory_config.rs b/tests/unit/core/core_config_user_memory_config.rs index 78d6bd1..9ae8486 100644 --- a/tests/unit/core/core_config_user_memory_config.rs +++ b/tests/unit/core/core_config_user_memory_config.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/core/config/user_memory_config.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_default_config() { let config = UserMemoryConfig::default(); assert!(config.enabled); @@ -18,7 +18,7 @@ #[test] - + fn test_can_add_key() { let config = UserMemoryConfig::default(); assert!(config.can_add_key(0)); @@ -29,7 +29,7 @@ #[test] - + fn test_can_add_key_disabled() { let config = UserMemoryConfig { enabled: false, @@ -40,7 +40,7 @@ #[test] - + fn test_ttl_duration() { let config = UserMemoryConfig { default_ttl: 3600, @@ -54,7 +54,7 @@ #[test] - + fn test_ttl_duration_no_expiration() { let config = UserMemoryConfig { default_ttl: 0, @@ -66,7 +66,7 @@ #[test] - + fn test_has_expiration() { let config = UserMemoryConfig::default(); assert!(config.has_expiration()); diff --git a/tests/unit/core/core_kb.rs b/tests/unit/core/core_kb.rs index e4611e5..c2853ca 100644 --- a/tests/unit/core/core_kb.rs +++ b/tests/unit/core/core_kb.rs @@ -1,10 +1,10 @@ -//! Unit tests migrated from src/core/kb/mod.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + use tempfile::TempDir; #[tokio::test] @@ -12,14 +12,14 @@ let temp_dir = TempDir::new().unwrap(); let manager = KnowledgeBaseManager::new(temp_dir.path()); - // Test that manager is created successfully + assert!(manager.processor.chunk_size() == 1000); assert!(manager.processor.chunk_overlap() == 200); } #[test] - + fn test_collection_naming() { let bot_name = "testbot"; let kb_name = "docs"; diff --git a/tests/unit/core/core_kb_document_processor.rs b/tests/unit/core/core_kb_document_processor.rs index 5e692f6..be852b5 100644 --- a/tests/unit/core/core_kb_document_processor.rs +++ b/tests/unit/core/core_kb_document_processor.rs @@ -1,41 +1,41 @@ -//! Unit tests migrated from src/core/kb/document_processor.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_chunk_creation() { let processor = DocumentProcessor::default(); let text = "This is a test document with some content that needs to be chunked properly. " .repeat(20); let chunks = processor.create_chunks(&text, Path::new("test.txt")); - // Verify chunks are created + assert!(!chunks.is_empty()); - // Verify chunk size + for chunk in &chunks { assert!(chunk.content.len() <= processor.chunk_size); } - // Verify overlap exists + if chunks.len() > 1 { let first_end = &chunks[0].content[chunks[0].content.len().saturating_sub(100)..]; let second_start = &chunks[1].content[..100.min(chunks[1].content.len())]; - // There should be some overlap + assert!(first_end.chars().any(|c| second_start.contains(c))); } } #[test] - + fn test_format_detection() { assert_eq!( DocumentFormat::from_extension(Path::new("test.pdf")), @@ -61,7 +61,7 @@ #[test] - + fn test_text_cleaning() { let processor = DocumentProcessor::default(); let dirty_text = " This is\n\n\na test\r\nwith multiple spaces "; diff --git a/tests/unit/core/core_kb_embedding_generator.rs b/tests/unit/core/core_kb_embedding_generator.rs index 68ce6ec..52cc287 100644 --- a/tests/unit/core/core_kb_embedding_generator.rs +++ b/tests/unit/core/core_kb_embedding_generator.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/core/kb/embedding_generator.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_dimension_detection() { assert_eq!(EmbeddingConfig::detect_dimensions("bge-small-en"), 384); assert_eq!(EmbeddingConfig::detect_dimensions("all-mpnet-base-v2"), 768); @@ -24,7 +24,7 @@ let text = "This is a test\n\nWith multiple lines"; let _generator = EmbeddingGenerator::new("http://localhost:8082".to_string()); - // This would test actual embedding generation if service is available - // For unit tests, we just verify the structure is correct + + assert!(!text.is_empty()); } \ No newline at end of file diff --git a/tests/unit/core/core_kb_kb_indexer.rs b/tests/unit/core/core_kb_kb_indexer.rs index 4c5ed9c..db153bd 100644 --- a/tests/unit/core/core_kb_kb_indexer.rs +++ b/tests/unit/core/core_kb_kb_indexer.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/core/kb/kb_indexer.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_collection_name_generation() { let bot_name = "mybot"; let kb_name = "docs"; @@ -18,7 +18,7 @@ #[test] - + fn test_qdrant_point_creation() { let chunk = TextChunk { content: "Test content".to_string(), diff --git a/tests/unit/core/core_oauth.rs b/tests/unit/core/core_oauth.rs index f88a9ba..fb68adf 100644 --- a/tests/unit/core/core_oauth.rs +++ b/tests/unit/core/core_oauth.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/core/oauth/mod.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_provider_from_str() { assert_eq!( OAuthProvider::from_str("google"), @@ -28,7 +28,7 @@ #[test] - + fn test_oauth_state_encode_decode() { let state = OAuthState::new(OAuthProvider::Google, Some("/dashboard".to_string())); let encoded = state.encode(); @@ -41,7 +41,7 @@ #[test] - + fn test_oauth_config_validation() { let valid_config = OAuthConfig::new( OAuthProvider::Google, diff --git a/tests/unit/core/core_oauth_providers.rs b/tests/unit/core/core_oauth_providers.rs index b66daf9..4efa53c 100644 --- a/tests/unit/core/core_oauth_providers.rs +++ b/tests/unit/core/core_oauth_providers.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/core/oauth/providers.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_build_auth_url() { let config = OAuthConfig::new( OAuthProvider::Google, @@ -27,7 +27,7 @@ #[test] - + fn test_load_oauth_config() { let mut bot_config = HashMap::new(); bot_config.insert("oauth-google-enabled".to_string(), "true".to_string()); @@ -50,7 +50,7 @@ #[test] - + fn test_disabled_provider() { let mut bot_config = HashMap::new(); bot_config.insert("oauth-google-enabled".to_string(), "false".to_string()); diff --git a/tests/unit/core/core_package_manager_cache.rs b/tests/unit/core/core_package_manager_cache.rs index 022fa87..8f2d503 100644 --- a/tests/unit/core/core_package_manager_cache.rs +++ b/tests/unit/core/core_package_manager_cache.rs @@ -1,10 +1,10 @@ -//! Unit tests migrated from src/core/package_manager/cache.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + use std::io::Write; use tempfile::TempDir; @@ -32,7 +32,7 @@ sha256 = "" #[test] - + fn test_extract_filename() { assert_eq!( DownloadCache::extract_filename("https://example.com/path/file.tar.gz"), @@ -47,7 +47,7 @@ sha256 = "" #[test] - + fn test_cache_creation() -> Result<()> { let temp_dir = TempDir::new()?; create_test_config(temp_dir.path())?; @@ -62,25 +62,25 @@ sha256 = "" #[test] - + fn test_is_cached() -> Result<()> { let temp_dir = TempDir::new()?; create_test_config(temp_dir.path())?; let cache = DownloadCache::new(temp_dir.path())?; - // Initially not cached + assert!(!cache.is_cached("test.tar.gz")); - // Create a cached file + let cache_path = cache.get_cache_path("test.tar.gz"); let mut file = fs::File::create(&cache_path)?; file.write_all(b"test content")?; - // Now it should be cached + assert!(cache.is_cached("test.tar.gz")); - // Empty file should not count as cached + let empty_path = cache.get_cache_path("empty.tar.gz"); fs::File::create(&empty_path)?; assert!(!cache.is_cached("empty.tar.gz")); @@ -90,24 +90,24 @@ sha256 = "" #[test] - + fn test_resolve_url() -> Result<()> { let temp_dir = TempDir::new()?; create_test_config(temp_dir.path())?; let cache = DownloadCache::new(temp_dir.path())?; - // Test with uncached URL + let result = cache.resolve_url("https://example.com/newfile.tar.gz"); assert!(!result.is_cached()); assert_eq!(result.url(), Some("https://example.com/newfile.tar.gz")); - // Create cached file + let cache_path = cache.get_cache_path("newfile.tar.gz"); let mut file = fs::File::create(&cache_path)?; file.write_all(b"cached content")?; - // Now it should resolve to cached + let result = cache.resolve_url("https://example.com/newfile.tar.gz"); assert!(result.is_cached()); assert!(result.url().is_none()); @@ -117,7 +117,7 @@ sha256 = "" #[test] - + fn test_get_component() -> Result<()> { let temp_dir = TempDir::new()?; create_test_config(temp_dir.path())?; @@ -136,14 +136,14 @@ sha256 = "" #[test] - + fn test_list_cached() -> Result<()> { let temp_dir = TempDir::new()?; create_test_config(temp_dir.path())?; let cache = DownloadCache::new(temp_dir.path())?; - // Create some cached files + fs::write(cache.get_cache_path("file1.tar.gz"), "content1")?; fs::write(cache.get_cache_path("file2.zip"), "content2")?; @@ -157,19 +157,19 @@ sha256 = "" #[test] - + fn test_cache_size() -> Result<()> { let temp_dir = TempDir::new()?; create_test_config(temp_dir.path())?; let cache = DownloadCache::new(temp_dir.path())?; - // Initially empty + assert_eq!(cache.cache_size()?, 0); - // Add files - fs::write(cache.get_cache_path("file1.txt"), "12345")?; // 5 bytes - fs::write(cache.get_cache_path("file2.txt"), "1234567890")?; // 10 bytes + + fs::write(cache.get_cache_path("file1.txt"), "12345")?; + fs::write(cache.get_cache_path("file2.txt"), "1234567890")?; assert_eq!(cache.cache_size()?, 15); @@ -178,14 +178,14 @@ sha256 = "" #[test] - + fn test_clear_cache() -> Result<()> { let temp_dir = TempDir::new()?; create_test_config(temp_dir.path())?; let cache = DownloadCache::new(temp_dir.path())?; - // Create some cached files + fs::write(cache.get_cache_path("file1.tar.gz"), "content1")?; fs::write(cache.get_cache_path("file2.zip"), "content2")?; diff --git a/tests/unit/core/core_package_manager_setup_directory_setup.rs b/tests/unit/core/core_package_manager_setup_directory_setup.rs index ecc792d..209514e 100644 --- a/tests/unit/core/core_package_manager_setup_directory_setup.rs +++ b/tests/unit/core/core_package_manager_setup_directory_setup.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/core/package_manager/setup/directory_setup.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_directory_setup_creation() { let setup = DirectorySetup::new( "http://localhost:8080".to_string(), diff --git a/tests/unit/core/core_package_manager_setup_email_setup.rs b/tests/unit/core/core_package_manager_setup_email_setup.rs index bcefb33..ebf2f3b 100644 --- a/tests/unit/core/core_package_manager_setup_email_setup.rs +++ b/tests/unit/core/core_package_manager_setup_email_setup.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/core/package_manager/setup/email_setup.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_email_setup_creation() { let setup = EmailSetup::new( "http://localhost:8080".to_string(), @@ -28,6 +28,6 @@ assert!(config_path.exists()); - // Cleanup + let _ = std::fs::remove_file(config_path); } \ No newline at end of file diff --git a/tests/unit/core/core_rate_limit.rs b/tests/unit/core/core_rate_limit.rs index 9f370b7..64a4f39 100644 --- a/tests/unit/core/core_rate_limit.rs +++ b/tests/unit/core/core_rate_limit.rs @@ -1,29 +1,29 @@ -//! Unit tests migrated from src/core/rate_limit.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[tokio::test] async fn test_keyed_rate_limiter() { let limiter = KeyedRateLimiter::new(2, 2); - // First two requests should pass + assert!(limiter.check("test_ip").await); assert!(limiter.check("test_ip").await); - // Third request should be rate limited + assert!(!limiter.check("test_ip").await); - // Different key should pass + assert!(limiter.check("other_ip").await); } #[test] - + fn test_rate_limit_config_default() { let config = RateLimitConfig::default(); assert_eq!(config.api_rps, 100); @@ -34,7 +34,7 @@ #[test] - + fn test_get_limiter_type() { assert!(matches!(get_limiter_type("/api/users"), LimiterType::Api)); assert!(matches!(get_limiter_type("/auth/login"), LimiterType::Auth)); diff --git a/tests/unit/core/core_secrets.rs b/tests/unit/core/core_secrets.rs index 636ae34..e063b29 100644 --- a/tests/unit/core/core_secrets.rs +++ b/tests/unit/core/core_secrets.rs @@ -1,12 +1,12 @@ -//! Unit tests migrated from src/core/secrets/mod.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver - /// Helper function to parse database URL into HashMap for tests + + fn parse_database_url(url: &str) -> Result> { let mut result = HashMap::new(); if let Some(stripped) = url.strip_prefix("postgres://") { @@ -44,7 +44,7 @@ #[test] - + fn test_parse_database_url() { let parsed = parse_database_url("postgres://user:pass@localhost:5432/mydb").unwrap(); assert_eq!(parsed.get("username"), Some(&"user".to_string())); @@ -56,7 +56,7 @@ #[test] - + fn test_parse_database_url_minimal() { let parsed = parse_database_url("postgres://user@localhost/mydb").unwrap(); assert_eq!(parsed.get("username"), Some(&"user".to_string())); @@ -67,7 +67,7 @@ #[test] - + fn test_secret_paths() { assert_eq!(SecretPaths::DIRECTORY, "gbo/directory"); assert_eq!(SecretPaths::TABLES, "gbo/tables"); diff --git a/tests/unit/core/core_shared_models.rs b/tests/unit/core/core_shared_models.rs index 2790252..9474d83 100644 --- a/tests/unit/core/core_shared_models.rs +++ b/tests/unit/core/core_shared_models.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/core/shared/models.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_trigger_kind_conversion() { assert_eq!(TriggerKind::from_i32(0), Some(TriggerKind::Scheduled)); assert_eq!(TriggerKind::from_i32(1), Some(TriggerKind::TableUpdate)); @@ -23,7 +23,7 @@ #[test] - + fn test_trigger_kind_as_i32() { assert_eq!(TriggerKind::Scheduled as i32, 0); assert_eq!(TriggerKind::TableUpdate as i32, 1); diff --git a/tests/unit/core/core_shared_state.rs b/tests/unit/core/core_shared_state.rs index d832329..d051a80 100644 --- a/tests/unit/core/core_shared_state.rs +++ b/tests/unit/core/core_shared_state.rs @@ -1,10 +1,10 @@ -//! Unit tests migrated from src/core/shared/state.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[tokio::test] async fn test_extensions_insert_and_get() { diff --git a/tests/unit/core/core_shared_test_utils.rs b/tests/unit/core/core_shared_test_utils.rs index fa422ce..c6f4ffe 100644 --- a/tests/unit/core/core_shared_test_utils.rs +++ b/tests/unit/core/core_shared_test_utils.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/core/shared/test_utils.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use serde_json; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_mock_channel_adapter_creation() { let adapter = MockChannelAdapter::new("test"); assert_eq!(adapter.name(), "test"); @@ -20,7 +20,7 @@ use serde_json; #[cfg(feature = "llm")] #[test] - + fn test_mock_llm_provider_creation() { let provider = MockLLMProvider::new(); assert_eq!(provider.response, "Mock LLM response"); @@ -31,7 +31,7 @@ use serde_json; #[test] - + fn test_builder_defaults() { let builder = TestAppStateBuilder::new(); assert_eq!(builder.bucket_name, "test-bucket"); diff --git a/tests/unit/core/core_urls.rs b/tests/unit/core/core_urls.rs index b45ef33..9b0844c 100644 --- a/tests/unit/core/core_urls.rs +++ b/tests/unit/core/core_urls.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/core/urls.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_with_params() { let url = ApiUrls::with_params(ApiUrls::USER_BY_ID, &[("id", "123")]); assert_eq!(url, "/api/users/123"); @@ -16,7 +16,7 @@ #[test] - + fn test_with_query() { let url = ApiUrls::with_query(ApiUrls::USERS, &[("page", "1"), ("limit", "10")]); assert_eq!(url, "/api/users?page=1&limit=10"); @@ -24,7 +24,7 @@ #[test] - + fn test_multiple_params() { let url = ApiUrls::with_params( ApiUrls::EMAIL_CLICK, diff --git a/tests/unit/core/mod.rs b/tests/unit/core/mod.rs index d2e8e15..94de12c 100644 --- a/tests/unit/core/mod.rs +++ b/tests/unit/core/mod.rs @@ -1,4 +1,4 @@ -//! Tests for core module + mod core_bot_manager; mod core_config_model_routing_config; mod core_config_sse_config; diff --git a/tests/unit/drive/drive_vectordb.rs b/tests/unit/drive/drive_vectordb.rs index 11b0f61..1c98264 100644 --- a/tests/unit/drive/drive_vectordb.rs +++ b/tests/unit/drive/drive_vectordb.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/drive/vectordb.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_file_document_creation() { let file = FileDocument { id: "test-123".to_string(), @@ -32,7 +32,7 @@ #[test] - + fn test_should_index() { assert!(FileContentExtractor::should_index("text/plain", 1024)); assert!(FileContentExtractor::should_index("text/markdown", 5000)); diff --git a/tests/unit/drive/mod.rs b/tests/unit/drive/mod.rs index 3e8e13a..3eb4e40 100644 --- a/tests/unit/drive/mod.rs +++ b/tests/unit/drive/mod.rs @@ -1,2 +1,2 @@ -//! Tests for drive module + mod drive_vectordb; diff --git a/tests/unit/email/email_stalwart_client.rs b/tests/unit/email/email_stalwart_client.rs index cc8e9dc..3a36348 100644 --- a/tests/unit/email/email_stalwart_client.rs +++ b/tests/unit/email/email_stalwart_client.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/email/stalwart_client.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -15,11 +15,11 @@ use botserver::email::stalwart_client::RuleCondition; use botserver::email::stalwart_client::StalwartClient; use serde_json; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_generate_vacation_sieve_basic() { let client = StalwartClient::new("http://localhost", "test"); let config = AutoResponderConfig { @@ -42,7 +42,7 @@ use serde_json; #[test] - + fn test_generate_vacation_sieve_with_dates() { let client = StalwartClient::new("http://localhost", "test"); let config = AutoResponderConfig { @@ -64,7 +64,7 @@ use serde_json; #[test] - + fn test_generate_filter_sieve_move_rule() { let client = StalwartClient::new("http://localhost", "test"); let rule = EmailRule { @@ -96,7 +96,7 @@ use serde_json; #[test] - + fn test_generate_filter_sieve_disabled() { let client = StalwartClient::new("http://localhost", "test"); let rule = EmailRule { diff --git a/tests/unit/email/email_stalwart_sync.rs b/tests/unit/email/email_stalwart_sync.rs index 5fafc3e..113bdff 100644 --- a/tests/unit/email/email_stalwart_sync.rs +++ b/tests/unit/email/email_stalwart_sync.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/email/stalwart_sync.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -8,11 +8,11 @@ use botserver::email::stalwart_client::RuleAction; use botserver::email::stalwart_client::RuleCondition; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_new_distribution_list() { let list = NewDistributionList { bot_id: Uuid::new_v4(), @@ -32,7 +32,7 @@ use botserver::email::stalwart_client::RuleCondition; #[test] - + fn test_new_auto_responder() { let responder = NewAutoResponder { bot_id: Uuid::new_v4(), @@ -50,7 +50,7 @@ use botserver::email::stalwart_client::RuleCondition; #[test] - + fn test_new_email_rule() { let rule = NewEmailRule { bot_id: Uuid::new_v4(), @@ -78,7 +78,7 @@ use botserver::email::stalwart_client::RuleCondition; #[test] - + fn test_distribution_list_dto() { let dto = DistributionListDto { id: Uuid::new_v4(), diff --git a/tests/unit/email/email_vectordb.rs b/tests/unit/email/email_vectordb.rs index dab334c..4a3be62 100644 --- a/tests/unit/email/email_vectordb.rs +++ b/tests/unit/email/email_vectordb.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/email/vectordb.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_email_document_creation() { let email = EmailDocument { id: "test-123".to_string(), diff --git a/tests/unit/email/mod.rs b/tests/unit/email/mod.rs index af697a3..9737e92 100644 --- a/tests/unit/email/mod.rs +++ b/tests/unit/email/mod.rs @@ -1,4 +1,4 @@ -//! Tests for email module + mod email_stalwart_client; mod email_stalwart_sync; mod email_vectordb; diff --git a/tests/unit/llm/llm_cache_test.rs b/tests/unit/llm/llm_cache_test.rs index 1a448d5..89b4863 100644 --- a/tests/unit/llm/llm_cache_test.rs +++ b/tests/unit/llm/llm_cache_test.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/llm/cache_test.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,14 +7,14 @@ use serde_json; -// use super::super::...; - internal import removed -// use super::super::...; - internal import removed + + use async_trait::async_trait; use serde_json::json; use std::sync::Arc; use tokio::sync::mpsc; - // Mock LLM provider for testing + struct MockLLMProvider { response: String, call_count: std::sync::atomic::AtomicUsize, @@ -69,7 +69,7 @@ use serde_json; } } - // Mock embedding service for testing + struct MockEmbeddingService; #[async_trait] @@ -78,7 +78,7 @@ use serde_json; &self, text: &str, ) -> Result, Box> { - // Return a simple hash-based embedding for testing + let hash = text.bytes().fold(0u32, |acc, b| acc.wrapping_add(b as u32)); Ok(vec![hash as f32 / 255.0; 10]) } @@ -88,7 +88,7 @@ use serde_json; return 0.0; } - // Simple similarity based on difference + let diff: f32 = embedding1 .iter() .zip(embedding2.iter()) @@ -101,7 +101,7 @@ use serde_json; #[tokio::test] async fn test_exact_cache_hit() { - // Setup + let mock_provider = Arc::new(MockLLMProvider::new("Test response")); let cache_client = Arc::new(redis::Client::open("redis://127.0.0.1/").unwrap()); @@ -121,7 +121,7 @@ use serde_json; let model = "test-model"; let key = "test-key"; - // First call should hit the underlying provider + let result1 = cached_provider .generate(prompt, &messages, model, key) .await @@ -129,18 +129,18 @@ use serde_json; assert_eq!(result1, "Test response"); assert_eq!(mock_provider.get_call_count(), 1); - // Second call with same parameters should hit cache + let result2 = cached_provider .generate(prompt, &messages, model, key) .await .unwrap(); assert_eq!(result2, "Test response"); - assert_eq!(mock_provider.get_call_count(), 1); // Should not increase + assert_eq!(mock_provider.get_call_count(), 1); } #[tokio::test] async fn test_semantic_cache_hit() { - // Setup + let mock_provider = Arc::new(MockLLMProvider::new("Weather is sunny")); let cache_client = Arc::new(redis::Client::open("redis://127.0.0.1/").unwrap()); @@ -164,7 +164,7 @@ use serde_json; let model = "test-model"; let key = "test-key"; - // First call with one prompt + let result1 = cached_provider .generate("What's the weather?", &messages, model, key) .await @@ -172,22 +172,22 @@ use serde_json; assert_eq!(result1, "Weather is sunny"); assert_eq!(mock_provider.get_call_count(), 1); - // Second call with similar prompt should hit semantic cache + let result2 = cached_provider .generate("What is the weather?", &messages, model, key) .await .unwrap(); - // With our mock embedding service, similar strings should match - // In a real scenario, this would depend on actual semantic similarity - // For this test, we're checking that the provider is called twice - // (since our mock embedding is too simple for real semantic matching) + + + + assert_eq!(result2, "Weather is sunny"); assert_eq!(mock_provider.get_call_count(), 2); } #[tokio::test] async fn test_cache_miss_different_model() { - // Setup + let mock_provider = Arc::new(MockLLMProvider::new("Response")); let cache_client = Arc::new(redis::Client::open("redis://127.0.0.1/").unwrap()); @@ -199,14 +199,14 @@ use serde_json; let messages = json!([{"role": "user", "content": prompt}]); let key = "test-key"; - // First call with model1 + let _ = cached_provider .generate(prompt, &messages, "model1", key) .await .unwrap(); assert_eq!(mock_provider.get_call_count(), 1); - // Second call with different model should miss cache + let _ = cached_provider .generate(prompt, &messages, "model2", key) .await @@ -216,7 +216,7 @@ use serde_json; #[tokio::test] async fn test_cache_statistics() { - // Setup + let mock_provider = Arc::new(MockLLMProvider::new("Response")); let cache_client = Arc::new(redis::Client::open("redis://127.0.0.1/").unwrap()); @@ -230,10 +230,10 @@ use serde_json; let cached_provider = CachedLLMProvider::new(mock_provider, cache_client, config, None); - // Clear any existing cache + let _ = cached_provider.clear_cache(None).await; - // Generate some cache entries + let messages = json!([]); for i in 0..5 { let _ = cached_provider @@ -241,14 +241,14 @@ use serde_json; .await; } - // Hit some cache entries + for i in 0..3 { let _ = cached_provider .generate(&format!("prompt_{}", i), &messages, "model", "key") .await; } - // Get statistics + let stats = cached_provider.get_cache_stats().await.unwrap(); assert_eq!(stats.total_entries, 5); assert_eq!(stats.total_hits, 3); @@ -258,7 +258,7 @@ use serde_json; #[tokio::test] async fn test_stream_generation_with_cache() { - // Setup + let mock_provider = Arc::new(MockLLMProvider::new("Streamed response")); let cache_client = Arc::new(redis::Client::open("redis://127.0.0.1/").unwrap()); @@ -278,7 +278,7 @@ use serde_json; let model = "test-model"; let key = "test-key"; - // First stream call + let (tx1, mut rx1) = mpsc::channel(100); cached_provider .generate_stream(prompt, &messages, tx1, model, key) @@ -292,7 +292,7 @@ use serde_json; assert_eq!(result1, "Streamed response"); assert_eq!(mock_provider.get_call_count(), 1); - // Second stream call should use cache + let (tx2, mut rx2) = mpsc::channel(100); cached_provider .generate_stream(prompt, &messages, tx2, model, key) @@ -304,19 +304,19 @@ use serde_json; result2.push_str(&chunk); } assert!(result2.contains("Streamed response")); - assert_eq!(mock_provider.get_call_count(), 1); // Should still be 1 + assert_eq!(mock_provider.get_call_count(), 1); } #[test] - + fn test_cosine_similarity_calculation() { let service = LocalEmbeddingService::new( "http://localhost:8082".to_string(), "test-model".to_string(), ); - // Test identical vectors + let vec1 = vec![0.5, 0.5, 0.5]; let vec2 = vec![0.5, 0.5, 0.5]; let similarity = tokio::runtime::Runtime::new() @@ -324,7 +324,7 @@ use serde_json; .block_on(service.compute_similarity(&vec1, &vec2)); assert_eq!(similarity, 1.0); - // Test orthogonal vectors + let vec3 = vec![1.0, 0.0]; let vec4 = vec![0.0, 1.0]; let similarity = tokio::runtime::Runtime::new() @@ -332,7 +332,7 @@ use serde_json; .block_on(service.compute_similarity(&vec3, &vec4)); assert_eq!(similarity, 0.0); - // Test opposite vectors + let vec5 = vec![1.0, 1.0]; let vec6 = vec![-1.0, -1.0]; let similarity = tokio::runtime::Runtime::new() diff --git a/tests/unit/llm/llm_observability.rs b/tests/unit/llm/llm_observability.rs index 17d4743..1abcc2d 100644 --- a/tests/unit/llm/llm_observability.rs +++ b/tests/unit/llm/llm_observability.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/llm/observability.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_default_config() { let config = ObservabilityConfig::default(); assert!(config.enabled); @@ -18,26 +18,26 @@ #[test] - + fn test_calculate_cost() { let manager = ObservabilityManager::new(ObservabilityConfig::default()); - // GPT-4 cost + let cost = manager.calculate_cost("gpt-4", 1000, 500); assert!(cost > 0.0); - // Local model (free) + let cost = manager.calculate_cost("local", 1000, 500); assert_eq!(cost, 0.0); - // Unknown model defaults to free + let cost = manager.calculate_cost("unknown-model", 1000, 500); assert_eq!(cost, 0.0); } #[test] - + fn test_quick_stats() { let manager = ObservabilityManager::new(ObservabilityConfig::default()); let stats = manager.get_quick_stats(); @@ -49,7 +49,7 @@ #[test] - + fn test_start_span() { let manager = ObservabilityManager::new(ObservabilityConfig::default()); let trace_id = Uuid::new_v4(); @@ -63,13 +63,13 @@ #[test] - + fn test_end_span() { let manager = ObservabilityManager::new(ObservabilityConfig::default()); let trace_id = Uuid::new_v4(); let mut span = manager.start_span(trace_id, "test_operation", "test_component", None); - // Simulate some work + std::thread::sleep(std::time::Duration::from_millis(10)); manager.end_span(&mut span, TraceStatus::Ok, None); @@ -93,18 +93,18 @@ async fn test_budget_check() { let manager = ObservabilityManager::new(ObservabilityConfig::default()); - // Small cost should be OK + let result = manager.check_budget(1.0).await; assert_eq!(result, BudgetCheckResult::Ok); - // Large cost should exceed daily + let result = manager.check_budget(150.0).await; assert_eq!(result, BudgetCheckResult::DailyExceeded); } #[test] - + fn test_metrics_to_dynamic() { let metrics = LLMRequestMetrics { request_id: Uuid::new_v4(), diff --git a/tests/unit/llm/mod.rs b/tests/unit/llm/mod.rs index f29799c..f1552b5 100644 --- a/tests/unit/llm/mod.rs +++ b/tests/unit/llm/mod.rs @@ -1,3 +1,3 @@ -//! Tests for llm module + mod llm_cache_test; mod llm_observability; diff --git a/tests/unit/math_functions.rs b/tests/unit/math_functions.rs index 03307e2..4bd2d0b 100644 --- a/tests/unit/math_functions.rs +++ b/tests/unit/math_functions.rs @@ -483,7 +483,7 @@ fn test_arithmetic_expression() { let engine = Engine::new(); let result: i64 = engine.eval("2 + 3 * 4").unwrap(); - assert_eq!(result, 14); // Verify operator precedence + assert_eq!(result, 14); let result: i64 = engine.eval("(2 + 3) * 4").unwrap(); assert_eq!(result, 20); diff --git a/tests/unit/mod.rs b/tests/unit/mod.rs index 0883323..4c2a971 100644 --- a/tests/unit/mod.rs +++ b/tests/unit/mod.rs @@ -1,4 +1,4 @@ -//! Unit tests for botserver modules + mod attendance; mod basic; diff --git a/tests/unit/security/mod.rs b/tests/unit/security/mod.rs index 6cdab75..32c4f18 100644 --- a/tests/unit/security/mod.rs +++ b/tests/unit/security/mod.rs @@ -1,4 +1,4 @@ -//! Tests for security module + mod security_antivirus; mod security_ca; mod security_cert_pinning; diff --git a/tests/unit/security/security.rs b/tests/unit/security/security.rs index a20ad69..797ccbc 100644 --- a/tests/unit/security/security.rs +++ b/tests/unit/security/security.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/security/mod.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_convert_to_https() { assert_eq!( convert_to_https("http://localhost:8080"), @@ -23,7 +23,7 @@ #[test] - + fn test_get_secure_port() { assert_eq!(get_secure_port("api", 8080), 8443); assert_eq!(get_secure_port("llm", 8081), 8444); @@ -33,7 +33,7 @@ #[test] - + fn test_security_config_default() { let config = SecurityConfig::default(); assert!(config.tls_enabled); diff --git a/tests/unit/security/security_antivirus.rs b/tests/unit/security/security_antivirus.rs index 04a3b74..9f8dff0 100644 --- a/tests/unit/security/security_antivirus.rs +++ b/tests/unit/security/security_antivirus.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/security/antivirus.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_classify_threat() { assert_eq!( AntivirusManager::classify_threat("Win.Trojan.Generic"), @@ -30,7 +30,7 @@ #[test] - + fn test_assess_severity() { assert_eq!( AntivirusManager::assess_severity("Ransomware.Test"), diff --git a/tests/unit/security/security_ca.rs b/tests/unit/security/security_ca.rs index 145d6d1..6ffd8c9 100644 --- a/tests/unit/security/security_ca.rs +++ b/tests/unit/security/security_ca.rs @@ -1,15 +1,15 @@ -//! Unit tests migrated from src/security/ca.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + use tempfile::TempDir; #[test] - + fn test_ca_config_default() { let config = CaConfig::default(); assert_eq!(config.validity_days, 365); @@ -19,7 +19,7 @@ #[test] - + fn test_ca_manager_creation() { let temp_dir = TempDir::new().unwrap(); let mut config = CaConfig::default(); diff --git a/tests/unit/security/security_cert_pinning.rs b/tests/unit/security/security_cert_pinning.rs index 5e421ec..a80dc9b 100644 --- a/tests/unit/security/security_cert_pinning.rs +++ b/tests/unit/security/security_cert_pinning.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/security/cert_pinning.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_pinned_cert_creation() { let pin = PinnedCert::new( "api.example.com", @@ -22,7 +22,7 @@ #[test] - + fn test_backup_pin() { let pin = PinnedCert::backup( "api.example.com", @@ -35,7 +35,7 @@ #[test] - + fn test_config_add_pin() { let mut config = CertPinningConfig::default(); config.add_pin(PinnedCert::new( @@ -49,7 +49,7 @@ #[test] - + fn test_format_fingerprint() { let hash = vec![0xAB, 0xCD, 0xEF, 0x12]; let formatted = format_fingerprint(&hash); @@ -58,7 +58,7 @@ #[test] - + fn test_parse_fingerprint_hex() { let result = parse_fingerprint("AB:CD:EF:12").unwrap(); assert_eq!(result, vec![0xAB, 0xCD, 0xEF, 0x12]); @@ -66,7 +66,7 @@ #[test] - + fn test_parse_fingerprint_base64() { let original = vec![0xAB, 0xCD, 0xEF, 0x12]; let base64 = format!("sha256//{}", BASE64.encode(&original)); @@ -76,7 +76,7 @@ #[test] - + fn test_pinning_stats() { let mut config = CertPinningConfig::default(); config.add_pin(PinnedCert::new( @@ -103,22 +103,22 @@ #[test] - + fn test_pem_to_der() { - // Minimal test PEM (this is a mock, real certs would be longer) + let mock_pem = b"-----BEGIN CERTIFICATE----- MIIB -----END CERTIFICATE-----"; - // Should fail gracefully with invalid base64 + let result = pem_to_der(mock_pem); - // We expect this to fail because "MIIB" is incomplete base64 + assert!(result.is_err() || result.unwrap().len() > 0); } #[test] - + fn test_manager_disabled() { let mut config = CertPinningConfig::default(); config.enabled = false; diff --git a/tests/unit/security/security_integration.rs b/tests/unit/security/security_integration.rs index a325837..f62f110 100644 --- a/tests/unit/security/security_integration.rs +++ b/tests/unit/security/security_integration.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/security/integration.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_url_conversion() { let integration = TlsIntegration::new(true); @@ -30,7 +30,7 @@ #[test] - + fn test_postgres_url_update() { let integration = TlsIntegration::new(true); @@ -47,7 +47,7 @@ #[test] - + fn test_service_url() { let integration = TlsIntegration::new(true); @@ -65,7 +65,7 @@ #[test] - + fn test_secure_port() { let integration = TlsIntegration::new(true); diff --git a/tests/unit/security/security_mutual_tls.rs b/tests/unit/security/security_mutual_tls.rs index a09ce43..30e3639 100644 --- a/tests/unit/security/security_mutual_tls.rs +++ b/tests/unit/security/security_mutual_tls.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/security/mutual_tls.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_mtls_config_default() { let config = MtlsConfig::default(); assert!(!config.enabled); @@ -19,7 +19,7 @@ #[test] - + fn test_mtls_config_new() { let config = MtlsConfig::new( Some("ca_cert".to_string()), @@ -32,7 +32,7 @@ #[test] - + fn test_mtls_config_partial() { let config = MtlsConfig::new(Some("ca_cert".to_string()), None, None); assert!(!config.enabled); @@ -41,7 +41,7 @@ #[test] - + fn test_mtls_manager_validation() { let config = MtlsConfig { enabled: true, @@ -61,7 +61,7 @@ #[test] - + fn test_mtls_manager_invalid_cert() { let config = MtlsConfig { enabled: true, diff --git a/tests/unit/security/security_tls.rs b/tests/unit/security/security_tls.rs index f46ca39..c9ad532 100644 --- a/tests/unit/security/security_tls.rs +++ b/tests/unit/security/security_tls.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/security/tls.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_tls_config_default() { let config = TlsConfig::default(); assert!(config.enabled); @@ -18,7 +18,7 @@ #[test] - + fn test_service_tls_config() { let config = ServiceTlsConfig::new("test-service", 8443).with_mtls(); @@ -29,14 +29,14 @@ #[test] - + fn test_tls_registry() { let mut registry = TlsRegistry::new(); registry.register_defaults(); assert!(!registry.services().is_empty()); - // Check if main services are registered + let service_names: Vec<&str> = registry .services() .iter() diff --git a/tests/unit/sources/mod.rs b/tests/unit/sources/mod.rs index d68a70e..f20401d 100644 --- a/tests/unit/sources/mod.rs +++ b/tests/unit/sources/mod.rs @@ -1,2 +1,2 @@ -//! Tests for sources module + mod sources_mcp; diff --git a/tests/unit/sources/sources_mcp.rs b/tests/unit/sources/sources_mcp.rs index 860caf0..209ecd2 100644 --- a/tests/unit/sources/sources_mcp.rs +++ b/tests/unit/sources/sources_mcp.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/sources/mcp.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_server_type_icons() { assert_eq!(get_server_type_icon("filesystem"), "📁"); assert_eq!(get_server_type_icon("database"), "🗄️"); @@ -18,7 +18,7 @@ #[test] - + fn test_risk_level_class() { assert_eq!(get_risk_level_class(&ToolRiskLevel::Safe), "risk-safe"); assert_eq!( @@ -29,7 +29,7 @@ #[test] - + fn test_risk_level_name() { assert_eq!(get_risk_level_name(&ToolRiskLevel::Safe), "Safe"); assert_eq!(get_risk_level_name(&ToolRiskLevel::High), "High"); diff --git a/tests/unit/string_functions.rs b/tests/unit/string_functions.rs index 197daa5..b4856af 100644 --- a/tests/unit/string_functions.rs +++ b/tests/unit/string_functions.rs @@ -11,7 +11,7 @@ fn test_instr_finds_substring() { return 0; } match haystack.find(needle) { - Some(pos) => (pos + 1) as i64, // 1-based index + Some(pos) => (pos + 1) as i64, None => 0, } }); @@ -53,7 +53,7 @@ fn test_instr_case_sensitive() { }); let result: i64 = engine.eval(r#"INSTR("Hello", "hello")"#).unwrap(); - assert_eq!(result, 0); // Case sensitive, so not found + assert_eq!(result, 0); } diff --git a/tests/unit/timeseries/mod.rs b/tests/unit/timeseries/mod.rs index 7b5650c..2068866 100644 --- a/tests/unit/timeseries/mod.rs +++ b/tests/unit/timeseries/mod.rs @@ -1,2 +1,2 @@ -//! Tests for timeseries module + mod timeseries; diff --git a/tests/unit/timeseries/timeseries.rs b/tests/unit/timeseries/timeseries.rs index 5f2e5a8..e6fe414 100644 --- a/tests/unit/timeseries/timeseries.rs +++ b/tests/unit/timeseries/timeseries.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/timeseries/mod.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_metric_point_line_protocol() { let point = MetricPoint::new("test_measurement") .tag("host", "server01") @@ -26,7 +26,7 @@ #[test] - + fn test_metric_point_escaping() { let point = MetricPoint::new("test") .tag("key with space", "value,with=special") @@ -39,7 +39,7 @@ #[test] - + fn test_predefined_metrics() { let msg = Metrics::message("bot-1", "whatsapp", "incoming"); assert_eq!(msg.measurement, "messages"); diff --git a/tests/unit/vector_db/mod.rs b/tests/unit/vector_db/mod.rs index 7b7d0bf..20ed5cd 100644 --- a/tests/unit/vector_db/mod.rs +++ b/tests/unit/vector_db/mod.rs @@ -1,4 +1,4 @@ -//! Tests for vector_db module + mod vector_db_bm25_config; mod vector_db_hybrid_search; mod vector_db_vectordb_indexer; diff --git a/tests/unit/vector_db/vector_db_bm25_config.rs b/tests/unit/vector_db/vector_db_bm25_config.rs index d317629..b282004 100644 --- a/tests/unit/vector_db/vector_db_bm25_config.rs +++ b/tests/unit/vector_db/vector_db_bm25_config.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/vector-db/bm25_config.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_default_config() { let config = Bm25Config::default(); assert!(config.enabled); @@ -20,7 +20,7 @@ #[test] - + fn test_disabled_config() { let config = Bm25Config::disabled(); assert!(!config.enabled); @@ -29,7 +29,7 @@ #[test] - + fn test_with_params() { let config = Bm25Config::with_params(1.5, 0.5); assert!((config.k1 - 1.5).abs() < f32::EPSILON); @@ -38,7 +38,7 @@ #[test] - + fn test_validation_negative_k1() { let mut config = Bm25Config { k1: -1.0, @@ -50,7 +50,7 @@ #[test] - + fn test_validation_high_k1() { let mut config = Bm25Config { k1: 15.0, @@ -62,7 +62,7 @@ #[test] - + fn test_validation_b_range() { let mut config = Bm25Config { b: -0.5, @@ -81,7 +81,7 @@ #[test] - + fn test_has_preprocessing() { let config = Bm25Config::default(); assert!(config.has_preprocessing()); @@ -96,7 +96,7 @@ #[test] - + fn test_describe() { let config = Bm25Config::default(); let desc = config.describe(); @@ -109,7 +109,7 @@ #[test] - + fn test_is_stopword() { assert!(is_stopword("the")); assert!(is_stopword("THE")); @@ -122,7 +122,7 @@ #[test] - + fn test_stopwords_list() { assert!(!DEFAULT_STOPWORDS.is_empty()); assert!(DEFAULT_STOPWORDS.len() > 80); diff --git a/tests/unit/vector_db/vector_db_hybrid_search.rs b/tests/unit/vector_db/vector_db_hybrid_search.rs index 7c4a549..6213f96 100644 --- a/tests/unit/vector_db/vector_db_hybrid_search.rs +++ b/tests/unit/vector_db/vector_db_hybrid_search.rs @@ -1,5 +1,5 @@ -//! Unit tests migrated from src/vector-db/hybrid_search.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] @@ -7,11 +7,11 @@ use serde_json; -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_hybrid_config_default() { let config = HybridSearchConfig::default(); @@ -24,7 +24,7 @@ use serde_json; #[test] - + fn test_hybrid_config_search_modes() { let config = HybridSearchConfig::default(); assert!(config.use_sparse_search()); @@ -48,7 +48,7 @@ use serde_json; #[test] - + fn test_reciprocal_rank_fusion() { let config = HybridSearchConfig::default(); let engine = HybridSearchEngine::new(config, "http://localhost:6333", "test"); @@ -68,14 +68,14 @@ use serde_json; let fused = engine.reciprocal_rank_fusion(&sparse, &dense); assert!(!fused.is_empty()); - // doc1 and doc2 appear in both, should rank high + let top_ids: Vec<&str> = fused.iter().take(2).map(|(id, _)| id.as_str()).collect(); assert!(top_ids.contains(&"doc1") || top_ids.contains(&"doc2")); } #[test] - + fn test_query_decomposer_simple() { let decomposer = QueryDecomposer::new("http://localhost:8081", "none"); @@ -94,7 +94,7 @@ use serde_json; #[test] - + fn test_search_result_serialization() { let result = SearchResult { doc_id: "test123".to_string(), @@ -115,7 +115,7 @@ use serde_json; #[cfg(not(feature = "vectordb"))] #[test] - + fn test_fallback_bm25_index() { let mut index = BM25Index::new(); @@ -139,7 +139,7 @@ use serde_json; #[cfg(not(feature = "vectordb"))] #[test] - + fn test_fallback_bm25_disabled() { let mut index = BM25Index::new(); index.set_enabled(false); diff --git a/tests/unit/vector_db/vector_db_vectordb_indexer.rs b/tests/unit/vector_db/vector_db_vectordb_indexer.rs index da6e74d..09bee9c 100644 --- a/tests/unit/vector_db/vector_db_vectordb_indexer.rs +++ b/tests/unit/vector_db/vector_db_vectordb_indexer.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/vector-db/vectordb_indexer.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_indexing_stats_creation() { let stats = IndexingStats { emails_indexed: 10, diff --git a/tests/unit/weba/mod.rs b/tests/unit/weba/mod.rs index 5c09ec8..95cc5bd 100644 --- a/tests/unit/weba/mod.rs +++ b/tests/unit/weba/mod.rs @@ -1,2 +1,2 @@ -//! Tests for weba module + mod weba; diff --git a/tests/unit/weba/weba.rs b/tests/unit/weba/weba.rs index 82d9040..4161b05 100644 --- a/tests/unit/weba/weba.rs +++ b/tests/unit/weba/weba.rs @@ -1,5 +1,5 @@ -//! Unit tests for botserver weba module -//! Tests web application builder functionality + + use botserver::weba::{ slugify, WebApp, WebAppConfig, WebAppStatus, WebAppTemplate, WebaState, diff --git a/tests/unit/whatsapp/mod.rs b/tests/unit/whatsapp/mod.rs index 6e94ef1..8453468 100644 --- a/tests/unit/whatsapp/mod.rs +++ b/tests/unit/whatsapp/mod.rs @@ -1,2 +1,2 @@ -//! Tests for whatsapp module + mod whatsapp; diff --git a/tests/unit/whatsapp/whatsapp.rs b/tests/unit/whatsapp/whatsapp.rs index 8eaccba..9ef9589 100644 --- a/tests/unit/whatsapp/whatsapp.rs +++ b/tests/unit/whatsapp/whatsapp.rs @@ -1,14 +1,14 @@ -//! Unit tests migrated from src/whatsapp/mod.rs -//! These tests were originally in botserver and have been migrated to bottest. + + #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] -// Original: use super::*; - tests used internal functions from botserver + #[test] - + fn test_extract_text_message() { let message = WhatsAppMessage { id: "msg123".to_string(), @@ -33,7 +33,7 @@ #[test] - + fn test_extract_interactive_button() { let message = WhatsAppMessage { id: "msg123".to_string(),