Remove all code comments
This commit is contained in:
parent
8593b861b5
commit
3d0a9a843d
161 changed files with 1208 additions and 1208 deletions
|
|
@ -46,7 +46,7 @@ pub struct AssertionResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AssertionResult {
|
impl AssertionResult {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn pass(message: &str) -> Self {
|
pub fn pass(message: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
passed: true,
|
passed: true,
|
||||||
|
|
@ -56,7 +56,7 @@ impl AssertionResult {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn fail(message: &str, expected: &str, actual: &str) -> Self {
|
pub fn fail(message: &str, expected: &str, actual: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
passed: false,
|
passed: false,
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,13 @@ impl DesktopConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_args(mut self, args: Vec<String>) -> Self {
|
pub fn with_args(mut self, args: Vec<String>) -> Self {
|
||||||
self.args = args;
|
self.args = args;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_env(mut self, key: &str, value: &str) -> Self {
|
pub fn with_env(mut self, key: &str, value: &str) -> Self {
|
||||||
self.env_vars.insert(key.to_string(), value.to_string());
|
self.env_vars.insert(key.to_string(), value.to_string());
|
||||||
self
|
self
|
||||||
|
|
@ -55,7 +55,7 @@ impl DesktopConfig {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn with_timeout(mut self, timeout: Duration) -> Self {
|
pub const fn with_timeout(mut self, timeout: Duration) -> Self {
|
||||||
self.timeout = timeout;
|
self.timeout = timeout;
|
||||||
self
|
self
|
||||||
|
|
@ -70,7 +70,7 @@ pub enum Platform {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Platform {
|
impl Platform {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn current() -> Self {
|
pub const fn current() -> Self {
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
return Platform::Windows;
|
return Platform::Windows;
|
||||||
|
|
@ -91,7 +91,7 @@ pub struct DesktopApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DesktopApp {
|
impl DesktopApp {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn new(config: DesktopConfig) -> Self {
|
pub const fn new(config: DesktopConfig) -> Self {
|
||||||
Self {
|
Self {
|
||||||
config,
|
config,
|
||||||
|
|
@ -161,12 +161,12 @@ impl DesktopApp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn pid(&self) -> Option<u32> {
|
pub const fn pid(&self) -> Option<u32> {
|
||||||
self.pid
|
self.pid
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn platform(&self) -> Platform {
|
pub const fn platform(&self) -> Platform {
|
||||||
self.platform
|
self.platform
|
||||||
}
|
}
|
||||||
|
|
@ -269,22 +269,22 @@ pub enum ElementLocator {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ElementLocator {
|
impl ElementLocator {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn accessibility_id(id: &str) -> Self {
|
pub fn accessibility_id(id: &str) -> Self {
|
||||||
Self::AccessibilityId(id.to_string())
|
Self::AccessibilityId(id.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn name(name: &str) -> Self {
|
pub fn name(name: &str) -> Self {
|
||||||
Self::Name(name.to_string())
|
Self::Name(name.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn role(role: &str) -> Self {
|
pub fn role(role: &str) -> Self {
|
||||||
Self::Role(role.to_string())
|
Self::Role(role.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn path(path: &str) -> Self {
|
pub fn path(path: &str) -> Self {
|
||||||
Self::Path(path.to_string())
|
Self::Path(path.to_string())
|
||||||
}
|
}
|
||||||
|
|
@ -322,12 +322,12 @@ impl Element {
|
||||||
anyhow::bail!("Element clear not yet implemented")
|
anyhow::bail!("Element clear not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn text(&self) -> Option<&str> {
|
pub fn text(&self) -> Option<&str> {
|
||||||
self.value.as_deref()
|
self.value.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn is_displayed(&self) -> bool {
|
pub const fn is_displayed(&self) -> bool {
|
||||||
self.bounds.width > 0 && self.bounds.height > 0
|
self.bounds.width > 0 && self.bounds.height > 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn sample_config() -> HashMap<String, String> {
|
pub fn sample_config() -> HashMap<String, String> {
|
||||||
let mut config = HashMap::new();
|
let mut config = HashMap::new();
|
||||||
config.insert("llm-model".to_string(), "gpt-4".to_string());
|
config.insert("llm-model".to_string(), "gpt-4".to_string());
|
||||||
|
|
@ -16,7 +16,7 @@ pub fn sample_config() -> HashMap<String, String> {
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn sample_bot_config() -> Value {
|
pub fn sample_bot_config() -> Value {
|
||||||
json!({
|
json!({
|
||||||
"name": "test-bot",
|
"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 {
|
pub fn whatsapp_text_message(from: &str, text: &str) -> Value {
|
||||||
json!({
|
json!({
|
||||||
"object": "whatsapp_business_account",
|
"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 {
|
pub fn whatsapp_button_reply(from: &str, button_id: &str, button_text: &str) -> Value {
|
||||||
json!({
|
json!({
|
||||||
"object": "whatsapp_business_account",
|
"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 {
|
pub fn teams_message_activity(from_id: &str, from_name: &str, text: &str) -> Value {
|
||||||
json!({
|
json!({
|
||||||
"type": "message",
|
"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 {
|
pub fn openai_chat_request(messages: Vec<(&str, &str)>) -> Value {
|
||||||
let msgs: Vec<Value> = messages
|
let msgs: Vec<Value> = messages
|
||||||
.into_iter()
|
.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 {
|
pub fn openai_chat_response(content: &str) -> Value {
|
||||||
json!({
|
json!({
|
||||||
"id": format!("chatcmpl-{}", uuid::Uuid::new_v4()),
|
"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 {
|
pub fn openai_embedding_response(dimensions: usize) -> Value {
|
||||||
let embedding: Vec<f64> = (0..dimensions)
|
let embedding: Vec<f64> = (0..dimensions)
|
||||||
.map(|i| (i as f64) / (dimensions as f64))
|
.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<KBEntry> {
|
pub fn sample_kb_entries() -> Vec<KBEntry> {
|
||||||
vec![
|
vec![
|
||||||
KBEntry {
|
KBEntry {
|
||||||
|
|
@ -263,7 +263,7 @@ pub struct KBEntry {
|
||||||
pub tags: Vec<String>,
|
pub tags: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn sample_products() -> Vec<Product> {
|
pub fn sample_products() -> Vec<Product> {
|
||||||
vec![
|
vec![
|
||||||
Product {
|
Product {
|
||||||
|
|
@ -303,7 +303,7 @@ pub struct Product {
|
||||||
pub category: String,
|
pub category: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn sample_faqs() -> Vec<FAQ> {
|
pub fn sample_faqs() -> Vec<FAQ> {
|
||||||
vec![
|
vec![
|
||||||
FAQ {
|
FAQ {
|
||||||
|
|
@ -344,7 +344,7 @@ pub struct FAQ {
|
||||||
pub mod errors {
|
pub mod errors {
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn validation_error(field: &str, message: &str) -> Value {
|
pub fn validation_error(field: &str, message: &str) -> Value {
|
||||||
json!({
|
json!({
|
||||||
"error": {
|
"error": {
|
||||||
|
|
@ -358,7 +358,7 @@ pub mod errors {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn not_found(resource: &str, id: &str) -> Value {
|
pub fn not_found(resource: &str, id: &str) -> Value {
|
||||||
json!({
|
json!({
|
||||||
"error": {
|
"error": {
|
||||||
|
|
@ -368,7 +368,7 @@ pub mod errors {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn unauthorized() -> Value {
|
pub fn unauthorized() -> Value {
|
||||||
json!({
|
json!({
|
||||||
"error": {
|
"error": {
|
||||||
|
|
@ -378,7 +378,7 @@ pub mod errors {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn forbidden() -> Value {
|
pub fn forbidden() -> Value {
|
||||||
json!({
|
json!({
|
||||||
"error": {
|
"error": {
|
||||||
|
|
@ -388,7 +388,7 @@ pub mod errors {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn rate_limited(retry_after: u32) -> Value {
|
pub fn rate_limited(retry_after: u32) -> Value {
|
||||||
json!({
|
json!({
|
||||||
"error": {
|
"error": {
|
||||||
|
|
@ -399,7 +399,7 @@ pub mod errors {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn internal_error() -> Value {
|
pub fn internal_error() -> Value {
|
||||||
json!({
|
json!({
|
||||||
"error": {
|
"error": {
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ impl Default for QueueStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn admin_user() -> User {
|
pub fn admin_user() -> User {
|
||||||
User {
|
User {
|
||||||
email: "admin@test.com".to_string(),
|
email: "admin@test.com".to_string(),
|
||||||
|
|
@ -289,7 +289,7 @@ pub fn admin_user() -> User {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn attendant_user() -> User {
|
pub fn attendant_user() -> User {
|
||||||
User {
|
User {
|
||||||
email: "attendant@test.com".to_string(),
|
email: "attendant@test.com".to_string(),
|
||||||
|
|
@ -299,7 +299,7 @@ pub fn attendant_user() -> User {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn regular_user() -> User {
|
pub fn regular_user() -> User {
|
||||||
User {
|
User {
|
||||||
email: "user@test.com".to_string(),
|
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 {
|
pub fn user_with_email(email: &str) -> User {
|
||||||
User {
|
User {
|
||||||
email: email.to_string(),
|
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 {
|
pub fn customer(phone: &str) -> Customer {
|
||||||
Customer {
|
Customer {
|
||||||
phone: Some(phone.to_string()),
|
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 {
|
pub fn customer_on_channel(channel: Channel) -> Customer {
|
||||||
Customer {
|
Customer {
|
||||||
channel,
|
channel,
|
||||||
|
|
@ -335,7 +335,7 @@ pub fn customer_on_channel(channel: Channel) -> Customer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn teams_customer() -> Customer {
|
pub fn teams_customer() -> Customer {
|
||||||
Customer {
|
Customer {
|
||||||
channel: Channel::Teams,
|
channel: Channel::Teams,
|
||||||
|
|
@ -344,7 +344,7 @@ pub fn teams_customer() -> Customer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn web_customer() -> Customer {
|
pub fn web_customer() -> Customer {
|
||||||
Customer {
|
Customer {
|
||||||
channel: Channel::Web,
|
channel: Channel::Web,
|
||||||
|
|
@ -353,7 +353,7 @@ pub fn web_customer() -> Customer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn basic_bot(name: &str) -> Bot {
|
pub fn basic_bot(name: &str) -> Bot {
|
||||||
Bot {
|
Bot {
|
||||||
name: name.to_string(),
|
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 {
|
pub fn bot_with_kb(name: &str) -> Bot {
|
||||||
Bot {
|
Bot {
|
||||||
name: name.to_string(),
|
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 {
|
pub fn rule_based_bot(name: &str) -> Bot {
|
||||||
Bot {
|
Bot {
|
||||||
name: name.to_string(),
|
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 {
|
pub fn session_for(bot: &Bot, customer: &Customer) -> Session {
|
||||||
Session {
|
Session {
|
||||||
bot_id: bot.id,
|
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 {
|
pub fn active_session() -> Session {
|
||||||
Session {
|
Session {
|
||||||
state: SessionState::Active,
|
state: SessionState::Active,
|
||||||
|
|
@ -402,7 +402,7 @@ pub fn active_session() -> Session {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn incoming_message(content: &str) -> Message {
|
pub fn incoming_message(content: &str) -> Message {
|
||||||
Message {
|
Message {
|
||||||
direction: MessageDirection::Incoming,
|
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 {
|
pub fn outgoing_message(content: &str) -> Message {
|
||||||
Message {
|
Message {
|
||||||
direction: MessageDirection::Outgoing,
|
direction: MessageDirection::Outgoing,
|
||||||
|
|
@ -420,7 +420,7 @@ pub fn outgoing_message(content: &str) -> Message {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn message_in_session(
|
pub fn message_in_session(
|
||||||
session: &Session,
|
session: &Session,
|
||||||
content: &str,
|
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 {
|
pub fn queue_entry_for(customer: &Customer, session: &Session) -> QueueEntry {
|
||||||
QueueEntry {
|
QueueEntry {
|
||||||
customer_id: customer.id,
|
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 {
|
pub fn high_priority_queue_entry() -> QueueEntry {
|
||||||
QueueEntry {
|
QueueEntry {
|
||||||
priority: Priority::High,
|
priority: Priority::High,
|
||||||
|
|
@ -451,7 +451,7 @@ pub fn high_priority_queue_entry() -> QueueEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn urgent_queue_entry() -> QueueEntry {
|
pub fn urgent_queue_entry() -> QueueEntry {
|
||||||
QueueEntry {
|
QueueEntry {
|
||||||
priority: Priority::Urgent,
|
priority: Priority::Urgent,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_script(name: &str) -> Option<&'static str> {
|
pub fn get_script(name: &str) -> Option<&'static str> {
|
||||||
match name {
|
match name {
|
||||||
"greeting" => Some(GREETING_SCRIPT),
|
"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> {
|
pub fn available_scripts() -> Vec<&'static str> {
|
||||||
vec![
|
vec![
|
||||||
"greeting",
|
"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> {
|
pub fn all_scripts() -> HashMap<&'static str, &'static str> {
|
||||||
let mut scripts = HashMap::new();
|
let mut scripts = HashMap::new();
|
||||||
for name in available_scripts() {
|
for name in available_scripts() {
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ impl Default for TestConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestConfig {
|
impl TestConfig {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn minimal() -> Self {
|
pub const fn minimal() -> Self {
|
||||||
Self {
|
Self {
|
||||||
postgres: false,
|
postgres: false,
|
||||||
|
|
@ -47,31 +47,31 @@ impl TestConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn full() -> Self {
|
pub const fn full() -> Self {
|
||||||
Self {
|
Self {
|
||||||
postgres: false, // Botserver will bootstrap its own PostgreSQL
|
postgres: false,
|
||||||
minio: false, // Botserver will bootstrap its own MinIO
|
minio: false,
|
||||||
redis: false, // Botserver will bootstrap its own Redis
|
redis: false,
|
||||||
mock_zitadel: true,
|
mock_zitadel: true,
|
||||||
mock_llm: 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 {
|
pub const fn auto_install() -> Self {
|
||||||
Self {
|
Self {
|
||||||
postgres: false, // Botserver will install PostgreSQL
|
postgres: false,
|
||||||
minio: false, // Botserver will install MinIO
|
minio: false,
|
||||||
redis: false, // Botserver will install Redis
|
redis: false,
|
||||||
mock_zitadel: true,
|
mock_zitadel: true,
|
||||||
mock_llm: true,
|
mock_llm: true,
|
||||||
run_migrations: false, // Botserver handles migrations
|
run_migrations: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn database_only() -> Self {
|
pub const fn database_only() -> Self {
|
||||||
Self {
|
Self {
|
||||||
postgres: true,
|
postgres: true,
|
||||||
|
|
@ -80,7 +80,7 @@ impl TestConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn use_existing_stack() -> Self {
|
pub const fn use_existing_stack() -> Self {
|
||||||
Self {
|
Self {
|
||||||
postgres: false,
|
postgres: false,
|
||||||
|
|
@ -450,7 +450,7 @@ pub struct BotServerInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BotServerInstance {
|
impl BotServerInstance {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn existing(url: &str) -> Self {
|
pub fn existing(url: &str) -> Self {
|
||||||
let port = url
|
let port = url
|
||||||
.split(':')
|
.split(':')
|
||||||
|
|
@ -482,9 +482,9 @@ impl BotServerInstance {
|
||||||
let botserver_bin_path =
|
let botserver_bin_path =
|
||||||
std::fs::canonicalize(&botserver_bin).unwrap_or_else(|_| PathBuf::from(&botserver_bin));
|
std::fs::canonicalize(&botserver_bin).unwrap_or_else(|_| PathBuf::from(&botserver_bin));
|
||||||
let botserver_dir = botserver_bin_path
|
let botserver_dir = botserver_bin_path
|
||||||
.parent() // target/debug
|
.parent()
|
||||||
.and_then(|p| p.parent()) // target
|
.and_then(|p| p.parent())
|
||||||
.and_then(|p| p.parent()) // botserver
|
.and_then(|p| p.parent())
|
||||||
.map(std::path::Path::to_path_buf)
|
.map(std::path::Path::to_path_buf)
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
std::fs::canonicalize("../botserver")
|
std::fs::canonicalize("../botserver")
|
||||||
|
|
@ -514,7 +514,7 @@ impl BotServerInstance {
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
if process.is_some() {
|
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)...");
|
log::info!("Waiting for botserver to start (max {max_wait}s)...");
|
||||||
|
|
||||||
let client = reqwest::Client::builder()
|
let client = reqwest::Client::builder()
|
||||||
|
|
@ -562,7 +562,7 @@ pub struct BotUIInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BotUIInstance {
|
impl BotUIInstance {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn existing(url: &str) -> Self {
|
pub fn existing(url: &str) -> Self {
|
||||||
let port = url
|
let port = url
|
||||||
.split(':')
|
.split(':')
|
||||||
|
|
@ -597,9 +597,9 @@ impl BotUIInstance {
|
||||||
let botui_bin_path =
|
let botui_bin_path =
|
||||||
std::fs::canonicalize(&botui_bin).unwrap_or_else(|_| PathBuf::from(&botui_bin));
|
std::fs::canonicalize(&botui_bin).unwrap_or_else(|_| PathBuf::from(&botui_bin));
|
||||||
let botui_dir = botui_bin_path
|
let botui_dir = botui_bin_path
|
||||||
.parent() // target/debug
|
.parent()
|
||||||
.and_then(|p| p.parent()) // target
|
.and_then(|p| p.parent())
|
||||||
.and_then(|p| p.parent()) // botui
|
.and_then(|p| p.parent())
|
||||||
.map(std::path::Path::to_path_buf)
|
.map(std::path::Path::to_path_buf)
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
std::fs::canonicalize("../botui").unwrap_or_else(|_| PathBuf::from("../botui"))
|
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 {
|
pub const fn is_running(&self) -> bool {
|
||||||
self.process.is_some()
|
self.process.is_some()
|
||||||
}
|
}
|
||||||
|
|
@ -694,9 +694,9 @@ impl BotServerInstance {
|
||||||
let botserver_bin_path =
|
let botserver_bin_path =
|
||||||
std::fs::canonicalize(&botserver_bin).unwrap_or_else(|_| PathBuf::from(&botserver_bin));
|
std::fs::canonicalize(&botserver_bin).unwrap_or_else(|_| PathBuf::from(&botserver_bin));
|
||||||
let botserver_dir = botserver_bin_path
|
let botserver_dir = botserver_bin_path
|
||||||
.parent() // target/release
|
.parent()
|
||||||
.and_then(|p| p.parent()) // target
|
.and_then(|p| p.parent())
|
||||||
.and_then(|p| p.parent()) // botserver
|
.and_then(|p| p.parent())
|
||||||
.map(std::path::Path::to_path_buf)
|
.map(std::path::Path::to_path_buf)
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
std::fs::canonicalize("../botserver")
|
std::fs::canonicalize("../botserver")
|
||||||
|
|
@ -712,13 +712,13 @@ impl BotServerInstance {
|
||||||
log::info!("Using installers from: {installers_path:?}");
|
log::info!("Using installers from: {installers_path:?}");
|
||||||
|
|
||||||
let process = std::process::Command::new(&botserver_bin_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(&stack_path)
|
.arg(&stack_path)
|
||||||
.arg("--port")
|
.arg("--port")
|
||||||
.arg(port.to_string())
|
.arg(port.to_string())
|
||||||
.arg("--noconsole")
|
.arg("--noconsole")
|
||||||
.env_remove("RUST_LOG") // Remove to avoid logger conflict
|
.env_remove("RUST_LOG")
|
||||||
.env("BOTSERVER_INSTALLERS_PATH", &installers_path)
|
.env("BOTSERVER_INSTALLERS_PATH", &installers_path)
|
||||||
.env("DATABASE_URL", ctx.database_url())
|
.env("DATABASE_URL", ctx.database_url())
|
||||||
.env("DIRECTORY_URL", ctx.zitadel_url())
|
.env("DIRECTORY_URL", ctx.zitadel_url())
|
||||||
|
|
@ -764,7 +764,7 @@ impl BotServerInstance {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn is_running(&self) -> bool {
|
pub const fn is_running(&self) -> bool {
|
||||||
self.process.is_some()
|
self.process.is_some()
|
||||||
}
|
}
|
||||||
|
|
@ -1032,12 +1032,12 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_config_full() {
|
fn test_config_full() {
|
||||||
let config = TestConfig::full();
|
let config = TestConfig::full();
|
||||||
assert!(!config.postgres); // Botserver handles PostgreSQL
|
assert!(!config.postgres);
|
||||||
assert!(!config.minio); // Botserver handles MinIO
|
assert!(!config.minio);
|
||||||
assert!(!config.redis); // Botserver handles Redis
|
assert!(!config.redis);
|
||||||
assert!(config.mock_zitadel);
|
assert!(config.mock_zitadel);
|
||||||
assert!(config.mock_llm);
|
assert!(config.mock_llm);
|
||||||
assert!(!config.run_migrations); // Botserver handles migrations
|
assert!(!config.run_migrations);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ pub struct TestResults {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestResults {
|
impl TestResults {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(suite: &str) -> Self {
|
pub fn new(suite: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
suite: suite.to_string(),
|
suite: suite.to_string(),
|
||||||
|
|
@ -205,7 +205,7 @@ impl TestResults {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn success(&self) -> bool {
|
pub const fn success(&self) -> bool {
|
||||||
self.failed == 0 && self.errors.is_empty()
|
self.failed == 0 && self.errors.is_empty()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -563,12 +563,12 @@ impl MockLLM {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn url(&self) -> String {
|
pub fn url(&self) -> String {
|
||||||
format!("http://127.0.0.1:{}", self.port)
|
format!("http://127.0.0.1:{}", self.port)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn port(&self) -> u16 {
|
pub const fn port(&self) -> u16 {
|
||||||
self.port
|
self.port
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub struct MockRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MockRegistry {
|
impl MockRegistry {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
llm: None,
|
llm: None,
|
||||||
|
|
@ -31,22 +31,22 @@ impl MockRegistry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn llm(&self) -> &MockLLM {
|
pub const fn llm(&self) -> &MockLLM {
|
||||||
self.llm.as_ref().expect("LLM mock not configured")
|
self.llm.as_ref().expect("LLM mock not configured")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn whatsapp(&self) -> &MockWhatsApp {
|
pub const fn whatsapp(&self) -> &MockWhatsApp {
|
||||||
self.whatsapp.as_ref().expect("WhatsApp mock not configured")
|
self.whatsapp.as_ref().expect("WhatsApp mock not configured")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn teams(&self) -> &MockTeams {
|
pub const fn teams(&self) -> &MockTeams {
|
||||||
self.teams.as_ref().expect("Teams mock not configured")
|
self.teams.as_ref().expect("Teams mock not configured")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn zitadel(&self) -> &MockZitadel {
|
pub const fn zitadel(&self) -> &MockZitadel {
|
||||||
self.zitadel.as_ref().expect("Zitadel mock not configured")
|
self.zitadel.as_ref().expect("Zitadel mock not configured")
|
||||||
}
|
}
|
||||||
|
|
@ -98,7 +98,7 @@ pub struct Expectation {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Expectation {
|
impl Expectation {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(name: &str) -> Self {
|
pub fn new(name: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
|
|
@ -108,7 +108,7 @@ impl Expectation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn times(mut self, n: usize) -> Self {
|
pub const fn times(mut self, n: usize) -> Self {
|
||||||
self.expected_calls = Some(n);
|
self.expected_calls = Some(n);
|
||||||
self
|
self
|
||||||
|
|
@ -136,7 +136,7 @@ impl Expectation {
|
||||||
|
|
||||||
pub type ExpectationStore = Arc<Mutex<HashMap<String, Expectation>>>;
|
pub type ExpectationStore = Arc<Mutex<HashMap<String, Expectation>>>;
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new_expectation_store() -> ExpectationStore {
|
pub fn new_expectation_store() -> ExpectationStore {
|
||||||
Arc::new(Mutex::new(HashMap::new()))
|
Arc::new(Mutex::new(HashMap::new()))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -429,7 +429,7 @@ impl MockTeams {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn simulate_message(&self, from_id: &str, from_name: &str, text: &str) -> Activity {
|
pub fn simulate_message(&self, from_id: &str, from_name: &str, text: &str) -> Activity {
|
||||||
let conversation_id = format!("conv-{}", Uuid::new_v4());
|
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 {
|
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);
|
let mut activity = self.simulate_message(from_id, from_name, text);
|
||||||
|
|
||||||
|
|
@ -498,7 +498,7 @@ impl MockTeams {
|
||||||
activity
|
activity
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn simulate_member_added(&self, member_id: &str, member_name: &str) -> Activity {
|
pub fn simulate_member_added(&self, member_id: &str, member_name: &str) -> Activity {
|
||||||
let conversation_id = format!("conv-{}", Uuid::new_v4());
|
let conversation_id = format!("conv-{}", Uuid::new_v4());
|
||||||
|
|
||||||
|
|
@ -546,7 +546,7 @@ impl MockTeams {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn simulate_invoke(
|
pub fn simulate_invoke(
|
||||||
&self,
|
&self,
|
||||||
from_id: &str,
|
from_id: &str,
|
||||||
|
|
@ -599,7 +599,7 @@ impl MockTeams {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn simulate_adaptive_card_action(
|
pub fn simulate_adaptive_card_action(
|
||||||
&self,
|
&self,
|
||||||
from_id: &str,
|
from_id: &str,
|
||||||
|
|
@ -620,7 +620,7 @@ impl MockTeams {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn simulate_reaction(
|
pub fn simulate_reaction(
|
||||||
&self,
|
&self,
|
||||||
from_id: &str,
|
from_id: &str,
|
||||||
|
|
@ -698,12 +698,12 @@ impl MockTeams {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn sent_activities(&self) -> Vec<Activity> {
|
pub fn sent_activities(&self) -> Vec<Activity> {
|
||||||
self.sent_activities.lock().unwrap().clone()
|
self.sent_activities.lock().unwrap().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn sent_activities_containing(&self, text: &str) -> Vec<Activity> {
|
pub fn sent_activities_containing(&self, text: &str) -> Vec<Activity> {
|
||||||
self.sent_activities
|
self.sent_activities
|
||||||
.lock()
|
.lock()
|
||||||
|
|
@ -714,7 +714,7 @@ impl MockTeams {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn last_sent_activity(&self) -> Option<Activity> {
|
pub fn last_sent_activity(&self) -> Option<Activity> {
|
||||||
self.sent_activities.lock().unwrap().last().cloned()
|
self.sent_activities.lock().unwrap().last().cloned()
|
||||||
}
|
}
|
||||||
|
|
@ -730,32 +730,32 @@ impl MockTeams {
|
||||||
.insert(info.id.clone(), info);
|
.insert(info.id.clone(), info);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn url(&self) -> String {
|
pub fn url(&self) -> String {
|
||||||
format!("http://127.0.0.1:{}", self.port)
|
format!("http://127.0.0.1:{}", self.port)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn service_url(&self) -> String {
|
pub fn service_url(&self) -> String {
|
||||||
self.service_url.clone()
|
self.service_url.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn port(&self) -> u16 {
|
pub const fn port(&self) -> u16 {
|
||||||
self.port
|
self.port
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn bot_id(&self) -> &str {
|
pub fn bot_id(&self) -> &str {
|
||||||
&self.bot_id
|
&self.bot_id
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn bot_name(&self) -> &str {
|
pub fn bot_name(&self) -> &str {
|
||||||
&self.bot_name
|
&self.bot_name
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn tenant_id(&self) -> &str {
|
pub fn tenant_id(&self) -> &str {
|
||||||
&self.tenant_id
|
&self.tenant_id
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -481,7 +481,7 @@ impl MockWhatsApp {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn expect_send_message(&self, to: &str) -> MessageExpectation {
|
pub fn expect_send_message(&self, to: &str) -> MessageExpectation {
|
||||||
MessageExpectation {
|
MessageExpectation {
|
||||||
to: to.to_string(),
|
to: to.to_string(),
|
||||||
|
|
@ -490,7 +490,7 @@ impl MockWhatsApp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn expect_send_template(&self, name: &str) -> TemplateExpectation {
|
pub fn expect_send_template(&self, name: &str) -> TemplateExpectation {
|
||||||
TemplateExpectation {
|
TemplateExpectation {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
|
|
@ -759,12 +759,12 @@ impl MockWhatsApp {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn sent_messages(&self) -> Vec<SentMessage> {
|
pub fn sent_messages(&self) -> Vec<SentMessage> {
|
||||||
self.sent_messages.lock().unwrap().clone()
|
self.sent_messages.lock().unwrap().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn sent_messages_to(&self, phone: &str) -> Vec<SentMessage> {
|
pub fn sent_messages_to(&self, phone: &str) -> Vec<SentMessage> {
|
||||||
self.sent_messages
|
self.sent_messages
|
||||||
.lock()
|
.lock()
|
||||||
|
|
@ -775,7 +775,7 @@ impl MockWhatsApp {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn last_sent_message(&self) -> Option<SentMessage> {
|
pub fn last_sent_message(&self) -> Option<SentMessage> {
|
||||||
self.sent_messages.lock().unwrap().last().cloned()
|
self.sent_messages.lock().unwrap().last().cloned()
|
||||||
}
|
}
|
||||||
|
|
@ -784,32 +784,32 @@ impl MockWhatsApp {
|
||||||
self.sent_messages.lock().unwrap().clear();
|
self.sent_messages.lock().unwrap().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn url(&self) -> String {
|
pub fn url(&self) -> String {
|
||||||
format!("http://127.0.0.1:{}", self.port)
|
format!("http://127.0.0.1:{}", self.port)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn graph_api_url(&self) -> String {
|
pub fn graph_api_url(&self) -> String {
|
||||||
format!("http://127.0.0.1:{}/v17.0", self.port)
|
format!("http://127.0.0.1:{}/v17.0", self.port)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn port(&self) -> u16 {
|
pub const fn port(&self) -> u16 {
|
||||||
self.port
|
self.port
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn phone_number_id(&self) -> &str {
|
pub fn phone_number_id(&self) -> &str {
|
||||||
&self.phone_number_id
|
&self.phone_number_id
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn business_account_id(&self) -> &str {
|
pub fn business_account_id(&self) -> &str {
|
||||||
&self.business_account_id
|
&self.business_account_id
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn access_token(&self) -> &str {
|
pub fn access_token(&self) -> &str {
|
||||||
&self.access_token
|
&self.access_token
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ impl MockZitadel {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn create_test_user(&self, email: &str) -> TestUser {
|
pub fn create_test_user(&self, email: &str) -> TestUser {
|
||||||
let user = TestUser {
|
let user = TestUser {
|
||||||
id: Uuid::new_v4().to_string(),
|
id: Uuid::new_v4().to_string(),
|
||||||
|
|
@ -232,7 +232,7 @@ impl MockZitadel {
|
||||||
user
|
user
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn create_user(&self, user: TestUser) -> TestUser {
|
pub fn create_user(&self, user: TestUser) -> TestUser {
|
||||||
self.users
|
self.users
|
||||||
.lock()
|
.lock()
|
||||||
|
|
@ -487,7 +487,7 @@ impl MockZitadel {
|
||||||
format!("{header}.{payload}.{signature}")
|
format!("{header}.{payload}.{signature}")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn generate_token(&self, user: &TestUser) -> String {
|
pub fn generate_token(&self, user: &TestUser) -> String {
|
||||||
let access_token = format!("test_access_{}", Uuid::new_v4());
|
let access_token = format!("test_access_{}", Uuid::new_v4());
|
||||||
let now = SystemTime::now()
|
let now = SystemTime::now()
|
||||||
|
|
@ -520,22 +520,22 @@ impl MockZitadel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn url(&self) -> String {
|
pub fn url(&self) -> String {
|
||||||
format!("http://127.0.0.1:{}", self.port)
|
format!("http://127.0.0.1:{}", self.port)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn issuer(&self) -> String {
|
pub fn issuer(&self) -> String {
|
||||||
self.issuer.clone()
|
self.issuer.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn port(&self) -> u16 {
|
pub const fn port(&self) -> u16 {
|
||||||
self.port
|
self.port
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn discovery_url(&self) -> String {
|
pub fn discovery_url(&self) -> String {
|
||||||
format!("{}/.well-known/openid-configuration", self.url())
|
format!("{}/.well-known/openid-configuration", self.url())
|
||||||
}
|
}
|
||||||
|
|
@ -652,7 +652,7 @@ mod tests {
|
||||||
assert!(json.contains("access_token"));
|
assert!(json.contains("access_token"));
|
||||||
assert!(json.contains("Bearer"));
|
assert!(json.contains("Bearer"));
|
||||||
assert!(json.contains("refresh_token"));
|
assert!(json.contains("refresh_token"));
|
||||||
assert!(!json.contains("id_token")); // Should be skipped when None
|
assert!(!json.contains("id_token"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ impl PortAllocator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn allocate_range(count: usize) -> Vec<u16> {
|
pub fn allocate_range(count: usize) -> Vec<u16> {
|
||||||
(0..count).map(|_| Self::allocate()).collect()
|
(0..count).map(|_| Self::allocate()).collect()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,17 +154,17 @@ impl BrowserService {
|
||||||
anyhow::bail!("No supported browser found. Install Brave, Chrome, or Chromium.")
|
anyhow::bail!("No supported browser found. Install Brave, Chrome, or Chromium.")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn ws_url(&self) -> String {
|
pub fn ws_url(&self) -> String {
|
||||||
format!("ws://127.0.0.1:{}", self.port)
|
format!("ws://127.0.0.1:{}", self.port)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn http_url(&self) -> String {
|
pub fn http_url(&self) -> String {
|
||||||
format!("http://127.0.0.1:{}", self.port)
|
format!("http://127.0.0.1:{}", self.port)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn port(&self) -> u16 {
|
pub const fn port(&self) -> u16 {
|
||||||
self.port
|
self.port
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -343,32 +343,32 @@ impl MinioService {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn endpoint(&self) -> String {
|
pub fn endpoint(&self) -> String {
|
||||||
format!("http://127.0.0.1:{}", self.api_port)
|
format!("http://127.0.0.1:{}", self.api_port)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn console_url(&self) -> String {
|
pub fn console_url(&self) -> String {
|
||||||
format!("http://127.0.0.1:{}", self.console_port)
|
format!("http://127.0.0.1:{}", self.console_port)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn api_port(&self) -> u16 {
|
pub const fn api_port(&self) -> u16 {
|
||||||
self.api_port
|
self.api_port
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn console_port(&self) -> u16 {
|
pub const fn console_port(&self) -> u16 {
|
||||||
self.console_port
|
self.console_port
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn credentials(&self) -> (String, String) {
|
pub fn credentials(&self) -> (String, String) {
|
||||||
(self.access_key.clone(), self.secret_key.clone())
|
(self.access_key.clone(), self.secret_key.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn s3_config(&self) -> HashMap<String, String> {
|
pub fn s3_config(&self) -> HashMap<String, String> {
|
||||||
let mut config = HashMap::new();
|
let mut config = HashMap::new();
|
||||||
config.insert("endpoint_url".to_string(), self.endpoint());
|
config.insert("endpoint_url".to_string(), self.endpoint());
|
||||||
|
|
|
||||||
|
|
@ -386,8 +386,8 @@ unix_socket_directories = '{}'
|
||||||
&self.username,
|
&self.username,
|
||||||
"-d",
|
"-d",
|
||||||
&self.database_name,
|
&self.database_name,
|
||||||
"-t", // tuples only
|
"-t",
|
||||||
"-A", // unaligned
|
"-A",
|
||||||
"-c",
|
"-c",
|
||||||
sql,
|
sql,
|
||||||
])
|
])
|
||||||
|
|
@ -401,12 +401,12 @@ unix_socket_directories = '{}'
|
||||||
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
|
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn connection_string(&self) -> String {
|
pub fn connection_string(&self) -> String {
|
||||||
self.connection_string.clone()
|
self.connection_string.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn port(&self) -> u16 {
|
pub const fn port(&self) -> u16 {
|
||||||
self.port
|
self.port
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,7 @@ impl RedisService {
|
||||||
Ok(val)
|
Ok(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn connection_string(&self) -> String {
|
pub fn connection_string(&self) -> String {
|
||||||
match &self.password {
|
match &self.password {
|
||||||
Some(pw) => format!("redis://:{}@127.0.0.1:{}", pw, self.port),
|
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 {
|
pub fn url(&self) -> String {
|
||||||
self.connection_string()
|
self.connection_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn port(&self) -> u16 {
|
pub const fn port(&self) -> u16 {
|
||||||
self.port
|
self.port
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn host_port(&self) -> (&str, u16) {
|
pub const fn host_port(&self) -> (&str, u16) {
|
||||||
("127.0.0.1", self.port)
|
("127.0.0.1", self.port)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ impl Default for BrowserType {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BrowserType {
|
impl BrowserType {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn browser_name(&self) -> &'static str {
|
pub const fn browser_name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::Chrome => "chrome",
|
Self::Chrome => "chrome",
|
||||||
|
|
@ -40,7 +40,7 @@ impl BrowserType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn capability_name(&self) -> &'static str {
|
pub const fn capability_name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::Chrome => "goog:chromeOptions",
|
Self::Chrome => "goog:chromeOptions",
|
||||||
|
|
@ -130,24 +130,24 @@ impl BrowserConfig {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn with_browser(mut self, browser: BrowserType) -> Self {
|
pub const fn with_browser(mut self, browser: BrowserType) -> Self {
|
||||||
self.browser_type = browser;
|
self.browser_type = browser;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn with_debug_port(mut self, port: u16) -> Self {
|
pub const fn with_debug_port(mut self, port: u16) -> Self {
|
||||||
self.debug_port = port;
|
self.debug_port = port;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_webdriver_url(mut self, url: &str) -> Self {
|
pub fn with_webdriver_url(mut self, url: &str) -> Self {
|
||||||
if let Some(port_str) = url.split(':').next_back() {
|
if let Some(port_str) = url.split(':').next_back() {
|
||||||
if let Ok(port) = port_str.parse() {
|
if let Ok(port) = port_str.parse() {
|
||||||
|
|
@ -157,31 +157,31 @@ impl BrowserConfig {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn headless(mut self, headless: bool) -> Self {
|
pub const fn headless(mut self, headless: bool) -> Self {
|
||||||
self.headless = headless;
|
self.headless = headless;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn with_window_size(mut self, width: u32, height: u32) -> Self {
|
pub const fn with_window_size(mut self, width: u32, height: u32) -> Self {
|
||||||
self.window_width = width;
|
self.window_width = width;
|
||||||
self.window_height = height;
|
self.window_height = height;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn with_timeout(mut self, timeout: Duration) -> Self {
|
pub const fn with_timeout(mut self, timeout: Duration) -> Self {
|
||||||
self.timeout = timeout;
|
self.timeout = timeout;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn with_arg(self, _arg: &str) -> Self {
|
pub const fn with_arg(self, _arg: &str) -> Self {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_binary(mut self, path: &str) -> Self {
|
pub fn with_binary(mut self, path: &str) -> Self {
|
||||||
self.binary_path = Some(path.to_string());
|
self.binary_path = Some(path.to_string());
|
||||||
self
|
self
|
||||||
|
|
@ -213,7 +213,7 @@ impl BrowserConfig {
|
||||||
.map_err(|e| anyhow::anyhow!("Failed to build CDP browser config: {e}"))
|
.map_err(|e| anyhow::anyhow!("Failed to build CDP browser config: {e}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn build_capabilities(&self) -> serde_json::Value {
|
pub fn build_capabilities(&self) -> serde_json::Value {
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"browserName": self.browser_type.browser_name(),
|
"browserName": self.browser_type.browser_name(),
|
||||||
|
|
@ -897,10 +897,10 @@ impl Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn size(&self) -> Result<(u64, u64)> {
|
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 {
|
pub const fn locator(&self) -> &Locator {
|
||||||
&self.locator
|
&self.locator
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ impl Default for E2EConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl E2EConfig {
|
impl E2EConfig {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn to_browser_config(&self) -> BrowserConfig {
|
pub fn to_browser_config(&self) -> BrowserConfig {
|
||||||
BrowserConfig::default()
|
BrowserConfig::default()
|
||||||
.with_browser(self.browser)
|
.with_browser(self.browser)
|
||||||
|
|
@ -77,37 +77,37 @@ pub enum Locator {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Locator {
|
impl Locator {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn css(selector: &str) -> Self {
|
pub fn css(selector: &str) -> Self {
|
||||||
Self::Css(selector.to_string())
|
Self::Css(selector.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn xpath(expr: &str) -> Self {
|
pub fn xpath(expr: &str) -> Self {
|
||||||
Self::XPath(expr.to_string())
|
Self::XPath(expr.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn id(id: &str) -> Self {
|
pub fn id(id: &str) -> Self {
|
||||||
Self::Id(id.to_string())
|
Self::Id(id.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn name(name: &str) -> Self {
|
pub fn name(name: &str) -> Self {
|
||||||
Self::Name(name.to_string())
|
Self::Name(name.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn link_text(text: &str) -> Self {
|
pub fn link_text(text: &str) -> Self {
|
||||||
Self::LinkText(text.to_string())
|
Self::LinkText(text.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn class(name: &str) -> Self {
|
pub fn class(name: &str) -> Self {
|
||||||
Self::ClassName(name.to_string())
|
Self::ClassName(name.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn to_css_selector(&self) -> String {
|
pub fn to_css_selector(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Self::Css(s) => s.clone(),
|
Self::Css(s) => s.clone(),
|
||||||
|
|
@ -198,86 +198,86 @@ pub enum Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActionChain {
|
impl ActionChain {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
actions: Vec::new(),
|
actions: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn click(mut self, locator: Locator) -> Self {
|
pub fn click(mut self, locator: Locator) -> Self {
|
||||||
self.actions.push(Action::Click(locator));
|
self.actions.push(Action::Click(locator));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn double_click(mut self, locator: Locator) -> Self {
|
pub fn double_click(mut self, locator: Locator) -> Self {
|
||||||
self.actions.push(Action::DoubleClick(locator));
|
self.actions.push(Action::DoubleClick(locator));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn right_click(mut self, locator: Locator) -> Self {
|
pub fn right_click(mut self, locator: Locator) -> Self {
|
||||||
self.actions.push(Action::RightClick(locator));
|
self.actions.push(Action::RightClick(locator));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn move_to(mut self, locator: Locator) -> Self {
|
pub fn move_to(mut self, locator: Locator) -> Self {
|
||||||
self.actions.push(Action::MoveTo(locator));
|
self.actions.push(Action::MoveTo(locator));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn move_by(mut self, x: i32, y: i32) -> Self {
|
pub fn move_by(mut self, x: i32, y: i32) -> Self {
|
||||||
self.actions.push(Action::MoveByOffset(x, y));
|
self.actions.push(Action::MoveByOffset(x, y));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn key_down(mut self, key: Key) -> Self {
|
pub fn key_down(mut self, key: Key) -> Self {
|
||||||
self.actions.push(Action::KeyDown(key));
|
self.actions.push(Action::KeyDown(key));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn key_up(mut self, key: Key) -> Self {
|
pub fn key_up(mut self, key: Key) -> Self {
|
||||||
self.actions.push(Action::KeyUp(key));
|
self.actions.push(Action::KeyUp(key));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn send_keys(mut self, text: &str) -> Self {
|
pub fn send_keys(mut self, text: &str) -> Self {
|
||||||
self.actions.push(Action::SendKeys(text.to_string()));
|
self.actions.push(Action::SendKeys(text.to_string()));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn pause(mut self, duration: Duration) -> Self {
|
pub fn pause(mut self, duration: Duration) -> Self {
|
||||||
self.actions.push(Action::Pause(duration));
|
self.actions.push(Action::Pause(duration));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn drag_and_drop(mut self, source: Locator, target: Locator) -> Self {
|
pub fn drag_and_drop(mut self, source: Locator, target: Locator) -> Self {
|
||||||
self.actions.push(Action::DragAndDrop(source, target));
|
self.actions.push(Action::DragAndDrop(source, target));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn scroll_to(mut self, locator: Locator) -> Self {
|
pub fn scroll_to(mut self, locator: Locator) -> Self {
|
||||||
self.actions.push(Action::ScrollTo(locator));
|
self.actions.push(Action::ScrollTo(locator));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn scroll_by(mut self, x: i32, y: i32) -> Self {
|
pub fn scroll_by(mut self, x: i32, y: i32) -> Self {
|
||||||
self.actions.push(Action::ScrollByAmount(x, y));
|
self.actions.push(Action::ScrollByAmount(x, y));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn actions(&self) -> &[Action] {
|
pub fn actions(&self) -> &[Action] {
|
||||||
&self.actions
|
&self.actions
|
||||||
}
|
}
|
||||||
|
|
@ -302,7 +302,7 @@ pub struct Cookie {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cookie {
|
impl Cookie {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(name: &str, value: &str) -> Self {
|
pub fn new(name: &str, value: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
|
|
@ -316,25 +316,25 @@ impl Cookie {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_domain(mut self, domain: &str) -> Self {
|
pub fn with_domain(mut self, domain: &str) -> Self {
|
||||||
self.domain = Some(domain.to_string());
|
self.domain = Some(domain.to_string());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_path(mut self, path: &str) -> Self {
|
pub fn with_path(mut self, path: &str) -> Self {
|
||||||
self.path = Some(path.to_string());
|
self.path = Some(path.to_string());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn secure(mut self) -> Self {
|
pub const fn secure(mut self) -> Self {
|
||||||
self.secure = Some(true);
|
self.secure = Some(true);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn http_only(mut self) -> Self {
|
pub const fn http_only(mut self) -> Self {
|
||||||
self.http_only = Some(true);
|
self.http_only = Some(true);
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ pub struct LoginPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LoginPage {
|
impl LoginPage {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(base_url: &str) -> Self {
|
pub fn new(base_url: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
base_url: base_url.to_string(),
|
base_url: base_url.to_string(),
|
||||||
|
|
@ -34,24 +34,24 @@ impl LoginPage {
|
||||||
browser.goto(&format!("{}/login", self.base_url)).await
|
browser.goto(&format!("{}/login", self.base_url)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn email_input() -> Locator {
|
pub fn email_input() -> Locator {
|
||||||
Locator::css("#email, input[name='email'], input[type='email']")
|
Locator::css("#email, input[name='email'], input[type='email']")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn password_input() -> Locator {
|
pub fn password_input() -> Locator {
|
||||||
Locator::css("#password, input[name='password'], input[type='password']")
|
Locator::css("#password, input[name='password'], input[type='password']")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn login_button() -> Locator {
|
pub fn login_button() -> Locator {
|
||||||
Locator::css(
|
Locator::css(
|
||||||
"#login-button, button[type='submit'], input[type='submit'], .login-btn, .btn-login",
|
"#login-button, button[type='submit'], input[type='submit'], .login-btn, .btn-login",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn error_message() -> Locator {
|
pub fn error_message() -> Locator {
|
||||||
Locator::css(".error, .error-message, .alert-error, .alert-danger, [role='alert']")
|
Locator::css(".error, .error-message, .alert-error, .alert-danger, [role='alert']")
|
||||||
}
|
}
|
||||||
|
|
@ -106,7 +106,7 @@ pub struct DashboardPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DashboardPage {
|
impl DashboardPage {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(base_url: &str) -> Self {
|
pub fn new(base_url: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
base_url: base_url.to_string(),
|
base_url: base_url.to_string(),
|
||||||
|
|
@ -117,22 +117,22 @@ impl DashboardPage {
|
||||||
browser.goto(&format!("{}/dashboard", self.base_url)).await
|
browser.goto(&format!("{}/dashboard", self.base_url)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn stats_cards() -> Locator {
|
pub fn stats_cards() -> Locator {
|
||||||
Locator::css(".stats-card, .dashboard-stat, .metric-card")
|
Locator::css(".stats-card, .dashboard-stat, .metric-card")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn nav_menu() -> Locator {
|
pub fn nav_menu() -> Locator {
|
||||||
Locator::css("nav, .nav, .sidebar, .navigation")
|
Locator::css("nav, .nav, .sidebar, .navigation")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn user_profile() -> Locator {
|
pub fn user_profile() -> Locator {
|
||||||
Locator::css(".user-profile, .user-menu, .profile-dropdown, .avatar")
|
Locator::css(".user-profile, .user-menu, .profile-dropdown, .avatar")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn logout_button() -> Locator {
|
pub fn logout_button() -> Locator {
|
||||||
Locator::css(".logout, .logout-btn, #logout, a[href*='logout'], button:contains('Logout')")
|
Locator::css(".logout, .logout-btn, #logout, a[href*='logout'], button:contains('Logout')")
|
||||||
}
|
}
|
||||||
|
|
@ -176,7 +176,7 @@ pub struct ChatPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChatPage {
|
impl ChatPage {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(base_url: &str, bot_name: &str) -> Self {
|
pub fn new(base_url: &str, bot_name: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
base_url: base_url.to_string(),
|
base_url: base_url.to_string(),
|
||||||
|
|
@ -190,44 +190,44 @@ impl ChatPage {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn chat_input() -> Locator {
|
pub fn chat_input() -> Locator {
|
||||||
Locator::css(
|
Locator::css(
|
||||||
"#chat-input, .chat-input, input[name='message'], textarea[name='message'], .message-input",
|
"#chat-input, .chat-input, input[name='message'], textarea[name='message'], .message-input",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn send_button() -> Locator {
|
pub fn send_button() -> Locator {
|
||||||
Locator::css("#send, .send-btn, button[type='submit'], .send-message")
|
Locator::css("#send, .send-btn, button[type='submit'], .send-message")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn message_list() -> Locator {
|
pub fn message_list() -> Locator {
|
||||||
Locator::css(".messages, .message-list, .chat-messages, #messages")
|
Locator::css(".messages, .message-list, .chat-messages, #messages")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn bot_message() -> Locator {
|
pub fn bot_message() -> Locator {
|
||||||
Locator::css(".bot-message, .message-bot, .assistant-message, [data-role='bot']")
|
Locator::css(".bot-message, .message-bot, .assistant-message, [data-role='bot']")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn user_message() -> Locator {
|
pub fn user_message() -> Locator {
|
||||||
Locator::css(".user-message, .message-user, [data-role='user']")
|
Locator::css(".user-message, .message-user, [data-role='user']")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn typing_indicator() -> Locator {
|
pub fn typing_indicator() -> Locator {
|
||||||
Locator::css(".typing, .typing-indicator, .is-typing, [data-typing]")
|
Locator::css(".typing, .typing-indicator, .is-typing, [data-typing]")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn file_upload_button() -> Locator {
|
pub fn file_upload_button() -> Locator {
|
||||||
Locator::css(".upload-btn, .file-upload, input[type='file'], .attach-file")
|
Locator::css(".upload-btn, .file-upload, input[type='file'], .attach-file")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn quick_reply_buttons() -> Locator {
|
pub fn quick_reply_buttons() -> Locator {
|
||||||
Locator::css(".quick-replies, .quick-reply, .suggested-reply")
|
Locator::css(".quick-replies, .quick-reply, .suggested-reply")
|
||||||
}
|
}
|
||||||
|
|
@ -319,7 +319,7 @@ pub struct QueuePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QueuePage {
|
impl QueuePage {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(base_url: &str) -> Self {
|
pub fn new(base_url: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
base_url: base_url.to_string(),
|
base_url: base_url.to_string(),
|
||||||
|
|
@ -330,22 +330,22 @@ impl QueuePage {
|
||||||
browser.goto(&format!("{}/queue", self.base_url)).await
|
browser.goto(&format!("{}/queue", self.base_url)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn queue_panel() -> Locator {
|
pub fn queue_panel() -> Locator {
|
||||||
Locator::css(".queue-panel, .queue-container, #queue-panel")
|
Locator::css(".queue-panel, .queue-container, #queue-panel")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn queue_count() -> Locator {
|
pub fn queue_count() -> Locator {
|
||||||
Locator::css(".queue-count, .waiting-count, #queue-count")
|
Locator::css(".queue-count, .waiting-count, #queue-count")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn queue_entry() -> Locator {
|
pub fn queue_entry() -> Locator {
|
||||||
Locator::css(".queue-entry, .queue-item, .waiting-customer")
|
Locator::css(".queue-entry, .queue-item, .waiting-customer")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn take_next_button() -> Locator {
|
pub fn take_next_button() -> Locator {
|
||||||
Locator::css(".take-next, #take-next, button:contains('Take Next')")
|
Locator::css(".take-next, #take-next, button:contains('Take Next')")
|
||||||
}
|
}
|
||||||
|
|
@ -383,7 +383,7 @@ pub struct BotManagementPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BotManagementPage {
|
impl BotManagementPage {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(base_url: &str) -> Self {
|
pub fn new(base_url: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
base_url: base_url.to_string(),
|
base_url: base_url.to_string(),
|
||||||
|
|
@ -394,32 +394,32 @@ impl BotManagementPage {
|
||||||
browser.goto(&format!("{}/admin/bots", self.base_url)).await
|
browser.goto(&format!("{}/admin/bots", self.base_url)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn bot_list() -> Locator {
|
pub fn bot_list() -> Locator {
|
||||||
Locator::css(".bot-list, .bots-container, #bots")
|
Locator::css(".bot-list, .bots-container, #bots")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn bot_item() -> Locator {
|
pub fn bot_item() -> Locator {
|
||||||
Locator::css(".bot-item, .bot-card, .bot-entry")
|
Locator::css(".bot-item, .bot-card, .bot-entry")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn create_bot_button() -> Locator {
|
pub fn create_bot_button() -> Locator {
|
||||||
Locator::css(".create-bot, .new-bot, #create-bot, button:contains('Create')")
|
Locator::css(".create-bot, .new-bot, #create-bot, button:contains('Create')")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn bot_name_input() -> Locator {
|
pub fn bot_name_input() -> Locator {
|
||||||
Locator::css("#bot-name, input[name='name'], .bot-name-input")
|
Locator::css("#bot-name, input[name='name'], .bot-name-input")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn bot_description_input() -> Locator {
|
pub fn bot_description_input() -> Locator {
|
||||||
Locator::css("#bot-description, textarea[name='description'], .bot-description-input")
|
Locator::css("#bot-description, textarea[name='description'], .bot-description-input")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn save_button() -> Locator {
|
pub fn save_button() -> Locator {
|
||||||
Locator::css(".save-btn, button[type='submit'], #save, button:contains('Save')")
|
Locator::css(".save-btn, button[type='submit'], #save, button:contains('Save')")
|
||||||
}
|
}
|
||||||
|
|
@ -469,7 +469,7 @@ pub struct KnowledgeBasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KnowledgeBasePage {
|
impl KnowledgeBasePage {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(base_url: &str) -> Self {
|
pub fn new(base_url: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
base_url: base_url.to_string(),
|
base_url: base_url.to_string(),
|
||||||
|
|
@ -480,27 +480,27 @@ impl KnowledgeBasePage {
|
||||||
browser.goto(&format!("{}/admin/kb", self.base_url)).await
|
browser.goto(&format!("{}/admin/kb", self.base_url)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn kb_list() -> Locator {
|
pub fn kb_list() -> Locator {
|
||||||
Locator::css(".kb-list, .knowledge-base-list, #kb-list")
|
Locator::css(".kb-list, .knowledge-base-list, #kb-list")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn kb_entry() -> Locator {
|
pub fn kb_entry() -> Locator {
|
||||||
Locator::css(".kb-entry, .kb-item, .knowledge-entry")
|
Locator::css(".kb-entry, .kb-item, .knowledge-entry")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn upload_button() -> Locator {
|
pub fn upload_button() -> Locator {
|
||||||
Locator::css(".upload-btn, #upload, button:contains('Upload')")
|
Locator::css(".upload-btn, #upload, button:contains('Upload')")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn file_input() -> Locator {
|
pub fn file_input() -> Locator {
|
||||||
Locator::css("input[type='file']")
|
Locator::css("input[type='file']")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn search_input() -> Locator {
|
pub fn search_input() -> Locator {
|
||||||
Locator::css(".search-input, #search, input[placeholder*='search']")
|
Locator::css(".search-input, #search, input[placeholder*='search']")
|
||||||
}
|
}
|
||||||
|
|
@ -532,7 +532,7 @@ pub struct AnalyticsPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AnalyticsPage {
|
impl AnalyticsPage {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(base_url: &str) -> Self {
|
pub fn new(base_url: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
base_url: base_url.to_string(),
|
base_url: base_url.to_string(),
|
||||||
|
|
@ -545,17 +545,17 @@ impl AnalyticsPage {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn charts_container() -> Locator {
|
pub fn charts_container() -> Locator {
|
||||||
Locator::css(".charts, .analytics-charts, #charts")
|
Locator::css(".charts, .analytics-charts, #charts")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn date_range_picker() -> Locator {
|
pub fn date_range_picker() -> Locator {
|
||||||
Locator::css(".date-range, .date-picker, #date-range")
|
Locator::css(".date-range, .date-picker, #date-range")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn metric_card() -> Locator {
|
pub fn metric_card() -> Locator {
|
||||||
Locator::css(".metric-card, .analytics-metric, .stat-card")
|
Locator::css(".metric-card, .analytics-metric, .stat-card")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ pub fn browser_config() -> BrowserConfig {
|
||||||
BrowserConfig::default()
|
BrowserConfig::default()
|
||||||
.with_browser(BrowserType::Chrome)
|
.with_browser(BrowserType::Chrome)
|
||||||
.with_debug_port(debug_port)
|
.with_debug_port(debug_port)
|
||||||
.headless(headless) // false by default = show browser
|
.headless(headless)
|
||||||
.with_timeout(Duration::from_secs(30))
|
.with_timeout(Duration::from_secs(30))
|
||||||
.with_window_size(1920, 1080)
|
.with_window_size(1920, 1080)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -186,13 +186,13 @@ fn test_instr_function() {
|
||||||
let engine = create_basic_engine();
|
let engine = create_basic_engine();
|
||||||
|
|
||||||
let result: i64 = engine.eval(r#"INSTR("Hello World", "World")"#).unwrap();
|
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();
|
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();
|
let result: i64 = engine.eval(r#"INSTR("Hello World", "o")"#).unwrap();
|
||||||
assert_eq!(result, 5); // First occurrence
|
assert_eq!(result, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -483,7 +483,7 @@ fn test_while_loop() {
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.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::<f64>("10.0 / 0.0");
|
let result = engine.eval::<f64>("10.0 / 0.0");
|
||||||
match result {
|
match result {
|
||||||
Ok(val) => assert!(val.is_infinite() || val.is_nan()),
|
Ok(val) => assert!(val.is_infinite() || val.is_nan()),
|
||||||
Err(_) => (), // Division by zero error is also acceptable
|
Err(_) => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,20 +7,20 @@
|
||||||
|
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_module_exports() {
|
fn test_module_exports() {
|
||||||
// Test that types are properly exported
|
|
||||||
let _config = KeywordConfig::default();
|
let _config = KeywordConfig::default();
|
||||||
let _parser = KeywordParser::new();
|
let _parser = KeywordParser::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_respond_request_parse() {
|
fn test_respond_request_parse() {
|
||||||
let json = r#"{
|
let json = r#"{
|
||||||
"session_id": "123e4567-e89b-12d3-a456-426614174000",
|
"session_id": "123e4567-e89b-12d3-a456-426614174000",
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_config_defaults() {
|
fn test_config_defaults() {
|
||||||
let config = LlmAssistConfig::default();
|
let config = LlmAssistConfig::default();
|
||||||
assert!(!config.tips_enabled);
|
assert!(!config.tips_enabled);
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_fallback_tips_urgent() {
|
fn test_fallback_tips_urgent() {
|
||||||
let tips = generate_fallback_tips("This is URGENT! I need help immediately!");
|
let tips = generate_fallback_tips("This is URGENT! I need help immediately!");
|
||||||
assert!(!tips.is_empty());
|
assert!(!tips.is_empty());
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_fallback_tips_question() {
|
fn test_fallback_tips_question() {
|
||||||
let tips = generate_fallback_tips("How do I reset my password?");
|
let tips = generate_fallback_tips("How do I reset my password?");
|
||||||
assert!(!tips.is_empty());
|
assert!(!tips.is_empty());
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sentiment_positive() {
|
fn test_sentiment_positive() {
|
||||||
let sentiment = analyze_sentiment_keywords("Thank you so much! This is great!");
|
let sentiment = analyze_sentiment_keywords("Thank you so much! This is great!");
|
||||||
assert_eq!(sentiment.overall, "positive");
|
assert_eq!(sentiment.overall, "positive");
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sentiment_negative() {
|
fn test_sentiment_negative() {
|
||||||
let sentiment =
|
let sentiment =
|
||||||
analyze_sentiment_keywords("This is terrible! I'm very frustrated with this problem.");
|
analyze_sentiment_keywords("This is terrible! I'm very frustrated with this problem.");
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sentiment_urgent() {
|
fn test_sentiment_urgent() {
|
||||||
let sentiment = analyze_sentiment_keywords("I need help ASAP! This is urgent!");
|
let sentiment = analyze_sentiment_keywords("I need help ASAP! This is urgent!");
|
||||||
assert!(sentiment.urgency == "high" || sentiment.urgency == "urgent");
|
assert!(sentiment.urgency == "high" || sentiment.urgency == "urgent");
|
||||||
|
|
@ -65,7 +65,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_extract_json() {
|
fn test_extract_json() {
|
||||||
let response = "Here is the result: {\"key\": \"value\"} and some more text.";
|
let response = "Here is the result: {\"key\": \"value\"} and some more text.";
|
||||||
let json = extract_json(response);
|
let json = extract_json(response);
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_fallback_replies() {
|
fn test_fallback_replies() {
|
||||||
let replies = generate_fallback_replies();
|
let replies = generate_fallback_replies();
|
||||||
assert_eq!(replies.len(), 3);
|
assert_eq!(replies.len(), 3);
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_help_text() {
|
fn test_help_text() {
|
||||||
let help = get_help_text();
|
let help = get_help_text();
|
||||||
assert!(help.contains("/queue"));
|
assert!(help.contains("/queue"));
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
//! Tests for attendance module
|
|
||||||
mod attendance_llm_assist;
|
mod attendance_llm_assist;
|
||||||
mod attendance;
|
mod attendance;
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_is_label_line() {
|
fn test_is_label_line() {
|
||||||
assert!(is_label_line("start:"));
|
assert!(is_label_line("start:"));
|
||||||
assert!(is_label_line(" mainLoop:"));
|
assert!(is_label_line(" mainLoop:"));
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_extract_goto_target() {
|
fn test_extract_goto_target() {
|
||||||
assert_eq!(extract_goto_target("GOTO start"), Some("start".to_string()));
|
assert_eq!(extract_goto_target("GOTO start"), Some("start".to_string()));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_transform_line_simple_goto() {
|
fn test_transform_line_simple_goto() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
transform_line("GOTO start"),
|
transform_line("GOTO start"),
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_transform_line_if_then_goto() {
|
fn test_transform_line_if_then_goto() {
|
||||||
let result = transform_line("IF x < 10 THEN GOTO start");
|
let result = transform_line("IF x < 10 THEN GOTO start");
|
||||||
assert!(result.contains("if x < 10"));
|
assert!(result.contains("if x < 10"));
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_transform_line_if_goto_no_then() {
|
fn test_transform_line_if_goto_no_then() {
|
||||||
let result = transform_line("IF x < 10 GOTO start");
|
let result = transform_line("IF x < 10 GOTO start");
|
||||||
assert!(result.contains("if x < 10"));
|
assert!(result.contains("if x < 10"));
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_transform_line_not_goto() {
|
fn test_transform_line_not_goto() {
|
||||||
assert_eq!(transform_line("TALK \"Hello\""), "TALK \"Hello\"");
|
assert_eq!(transform_line("TALK \"Hello\""), "TALK \"Hello\"");
|
||||||
assert_eq!(transform_line("x = x + 1"), "x = x + 1");
|
assert_eq!(transform_line("x = x + 1"), "x = x + 1");
|
||||||
|
|
@ -82,17 +82,17 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_has_goto_constructs() {
|
fn test_has_goto_constructs() {
|
||||||
assert!(has_goto_constructs("start:\nTALK \"hi\"\nGOTO start"));
|
assert!(has_goto_constructs("start:\nTALK \"hi\"\nGOTO start"));
|
||||||
assert!(has_goto_constructs("IF x > 0 THEN GOTO done"));
|
assert!(has_goto_constructs("IF x > 0 THEN GOTO done"));
|
||||||
assert!(!has_goto_constructs("TALK \"hello\"\nWAIT 1"));
|
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]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_transform_goto_simple() {
|
fn test_transform_goto_simple() {
|
||||||
let input = r#"start:
|
let input = r#"start:
|
||||||
TALK "Hello"
|
TALK "Hello"
|
||||||
|
|
@ -110,16 +110,16 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_transform_goto_no_goto() {
|
fn test_transform_goto_no_goto() {
|
||||||
let input = "TALK \"Hello\"\nTALK \"World\"";
|
let input = "TALK \"Hello\"\nTALK \"World\"";
|
||||||
let output = transform_goto(input);
|
let output = transform_goto(input);
|
||||||
assert_eq!(output, input); // Unchanged
|
assert_eq!(output, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_transform_goto_multiple_labels() {
|
fn test_transform_goto_multiple_labels() {
|
||||||
let input = r#"start:
|
let input = r#"start:
|
||||||
TALK "Start"
|
TALK "Start"
|
||||||
|
|
@ -139,7 +139,7 @@ done:
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_infinite_loop_protection() {
|
fn test_infinite_loop_protection() {
|
||||||
let output = transform_goto("loop:\nGOTO loop");
|
let output = transform_goto("loop:\nGOTO loop");
|
||||||
assert!(output.contains("__goto_max_iterations"));
|
assert!(output.contains("__goto_max_iterations"));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_a2a_message_creation() {
|
fn test_a2a_message_creation() {
|
||||||
let msg = A2AMessage::new(
|
let msg = A2AMessage::new(
|
||||||
"bot_a",
|
"bot_a",
|
||||||
|
|
@ -29,7 +29,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_a2a_message_response() {
|
fn test_a2a_message_response() {
|
||||||
let original = A2AMessage::new(
|
let original = A2AMessage::new(
|
||||||
"bot_a",
|
"bot_a",
|
||||||
|
|
@ -50,7 +50,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_message_type_display() {
|
fn test_message_type_display() {
|
||||||
assert_eq!(A2AMessageType::Request.to_string(), "request");
|
assert_eq!(A2AMessageType::Request.to_string(), "request");
|
||||||
assert_eq!(A2AMessageType::Response.to_string(), "response");
|
assert_eq!(A2AMessageType::Response.to_string(), "response");
|
||||||
|
|
@ -60,7 +60,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_message_type_from_str() {
|
fn test_message_type_from_str() {
|
||||||
assert_eq!(A2AMessageType::from("request"), A2AMessageType::Request);
|
assert_eq!(A2AMessageType::from("request"), A2AMessageType::Request);
|
||||||
assert_eq!(A2AMessageType::from("RESPONSE"), A2AMessageType::Response);
|
assert_eq!(A2AMessageType::from("RESPONSE"), A2AMessageType::Response);
|
||||||
|
|
@ -69,7 +69,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_a2a_config_default() {
|
fn test_a2a_config_default() {
|
||||||
let config = A2AConfig::default();
|
let config = A2AConfig::default();
|
||||||
assert!(config.enabled);
|
assert!(config.enabled);
|
||||||
|
|
@ -80,7 +80,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_message_not_expired() {
|
fn test_message_not_expired() {
|
||||||
let msg = A2AMessage::new(
|
let msg = A2AMessage::new(
|
||||||
"bot_a",
|
"bot_a",
|
||||||
|
|
@ -95,7 +95,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_max_hops_not_exceeded() {
|
fn test_max_hops_not_exceeded() {
|
||||||
let msg = A2AMessage::new(
|
let msg = A2AMessage::new(
|
||||||
"bot_a",
|
"bot_a",
|
||||||
|
|
@ -110,7 +110,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_max_hops_exceeded() {
|
fn test_max_hops_exceeded() {
|
||||||
let mut msg = A2AMessage::new(
|
let mut msg = A2AMessage::new(
|
||||||
"bot_a",
|
"bot_a",
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_trigger_from_keywords() {
|
fn test_trigger_from_keywords() {
|
||||||
let trigger = BotTrigger::from_keywords(vec!["finance".to_string(), "money".to_string()]);
|
let trigger = BotTrigger::from_keywords(vec!["finance".to_string(), "money".to_string()]);
|
||||||
assert_eq!(trigger.trigger_type, TriggerType::Keyword);
|
assert_eq!(trigger.trigger_type, TriggerType::Keyword);
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_match_bot_triggers() {
|
fn test_match_bot_triggers() {
|
||||||
let bots = vec![
|
let bots = vec![
|
||||||
SessionBot {
|
SessionBot {
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_match_tool_triggers() {
|
fn test_match_tool_triggers() {
|
||||||
let bots = vec![SessionBot {
|
let bots = vec![SessionBot {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_validate_role() {
|
fn test_validate_role() {
|
||||||
assert_eq!(validate_role("admin"), "admin");
|
assert_eq!(validate_role("admin"), "admin");
|
||||||
assert_eq!(validate_role("ADMIN"), "admin");
|
assert_eq!(validate_role("ADMIN"), "admin");
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_get_permissions_for_role() {
|
fn test_get_permissions_for_role() {
|
||||||
let admin_perms = get_permissions_for_role("admin");
|
let admin_perms = get_permissions_for_role("admin");
|
||||||
assert!(admin_perms.get("read").unwrap().as_bool().unwrap());
|
assert!(admin_perms.get("read").unwrap().as_bool().unwrap());
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_suggestion_json_context() {
|
fn test_suggestion_json_context() {
|
||||||
let suggestion = json!({
|
let suggestion = json!({
|
||||||
"type": "context",
|
"type": "context",
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_suggestion_json_tool_no_params() {
|
fn test_suggestion_json_tool_no_params() {
|
||||||
let suggestion = json!({
|
let suggestion = json!({
|
||||||
"type": "tool",
|
"type": "tool",
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_suggestion_json_tool_with_params() {
|
fn test_suggestion_json_tool_with_params() {
|
||||||
let params = vec!["query".to_string(), "products".to_string()];
|
let params = vec!["query".to_string(), "products".to_string()];
|
||||||
let suggestion = json!({
|
let suggestion = json!({
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_reflection_type_from_str() {
|
fn test_reflection_type_from_str() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ReflectionType::from("conversation_quality"),
|
ReflectionType::from("conversation_quality"),
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_reflection_config_default() {
|
fn test_reflection_config_default() {
|
||||||
let config = ReflectionConfig::default();
|
let config = ReflectionConfig::default();
|
||||||
assert!(!config.enabled);
|
assert!(!config.enabled);
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_reflection_result_new() {
|
fn test_reflection_result_new() {
|
||||||
let bot_id = Uuid::new_v4();
|
let bot_id = Uuid::new_v4();
|
||||||
let session_id = Uuid::new_v4();
|
let session_id = Uuid::new_v4();
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_reflection_result_from_json() {
|
fn test_reflection_result_from_json() {
|
||||||
let json_response = r#"{
|
let json_response = r#"{
|
||||||
"score": 7.5,
|
"score": 7.5,
|
||||||
|
|
@ -79,7 +79,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_reflection_result_needs_improvement() {
|
fn test_reflection_result_needs_improvement() {
|
||||||
let mut result =
|
let mut result =
|
||||||
ReflectionResult::new(Uuid::new_v4(), Uuid::new_v4(), ReflectionType::Performance);
|
ReflectionResult::new(Uuid::new_v4(), Uuid::new_v4(), ReflectionType::Performance);
|
||||||
|
|
@ -93,7 +93,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_extract_insights_from_text() {
|
fn test_extract_insights_from_text() {
|
||||||
let text = "Here are some insights:\n\
|
let text = "Here are some insights:\n\
|
||||||
1. Users prefer short responses\n\
|
1. Users prefer short responses\n\
|
||||||
|
|
@ -107,7 +107,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_reflection_type_prompt_template() {
|
fn test_reflection_type_prompt_template() {
|
||||||
let template = ReflectionType::ConversationQuality.prompt_template();
|
let template = ReflectionType::ConversationQuality.prompt_template();
|
||||||
assert!(template.contains("{conversation}"));
|
assert!(template.contains("{conversation}"));
|
||||||
|
|
@ -116,7 +116,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_reflection_result_summary() {
|
fn test_reflection_result_summary() {
|
||||||
let mut result =
|
let mut result =
|
||||||
ReflectionResult::new(Uuid::new_v4(), Uuid::new_v4(), ReflectionType::Performance);
|
ReflectionResult::new(Uuid::new_v4(), Uuid::new_v4(), ReflectionType::Performance);
|
||||||
|
|
@ -128,6 +128,6 @@
|
||||||
let summary = result.summary();
|
let summary = result.summary();
|
||||||
assert!(summary.contains("7.5"));
|
assert!(summary.contains("7.5"));
|
||||||
assert!(summary.contains("15"));
|
assert!(summary.contains("15"));
|
||||||
assert!(summary.contains("2")); // insights count
|
assert!(summary.contains("2"));
|
||||||
assert!(summary.contains("1")); // improvements count
|
assert!(summary.contains("1"));
|
||||||
}
|
}
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -13,7 +13,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_ubound() {
|
fn test_ubound() {
|
||||||
let arr: Vec<Dynamic> = vec![Dynamic::from(1), Dynamic::from(2), Dynamic::from(3)];
|
let arr: Vec<Dynamic> = vec![Dynamic::from(1), Dynamic::from(2), Dynamic::from(3)];
|
||||||
assert_eq!(arr.len() - 1, 2);
|
assert_eq!(arr.len() - 1, 2);
|
||||||
|
|
@ -21,7 +21,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_join() {
|
fn test_join() {
|
||||||
let arr = vec!["a", "b", "c"];
|
let arr = vec!["a", "b", "c"];
|
||||||
let result = arr.join("-");
|
let result = arr.join("-");
|
||||||
|
|
@ -30,7 +30,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_split() {
|
fn test_split() {
|
||||||
let s = "a,b,c";
|
let s = "a,b,c";
|
||||||
let parts: Vec<&str> = s.split(',').collect();
|
let parts: Vec<&str> = s.split(',').collect();
|
||||||
|
|
@ -39,7 +39,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_range() {
|
fn test_range() {
|
||||||
let range: Vec<i64> = (1..=5).collect();
|
let range: Vec<i64> = (1..=5).collect();
|
||||||
assert_eq!(range, vec![1, 2, 3, 4, 5]);
|
assert_eq!(range, vec![1, 2, 3, 4, 5]);
|
||||||
|
|
@ -47,9 +47,9 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_flatten() {
|
fn test_flatten() {
|
||||||
// Test flattening logic
|
|
||||||
let nested = vec![vec![1, 2], vec![3, 4]];
|
let nested = vec![vec![1, 2], vec![3, 4]];
|
||||||
let flat: Vec<i32> = nested.into_iter().flatten().collect();
|
let flat: Vec<i32> = nested.into_iter().flatten().collect();
|
||||||
assert_eq!(flat, vec![1, 2, 3, 4]);
|
assert_eq!(flat, vec![1, 2, 3, 4]);
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_contains_string() {
|
fn test_contains_string() {
|
||||||
let arr: Array = vec![
|
let arr: Array = vec![
|
||||||
Dynamic::from("Alice"),
|
Dynamic::from("Alice"),
|
||||||
|
|
@ -25,7 +25,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_contains_integer() {
|
fn test_contains_integer() {
|
||||||
let arr: Array = vec![
|
let arr: Array = vec![
|
||||||
Dynamic::from(1_i64),
|
Dynamic::from(1_i64),
|
||||||
|
|
@ -39,7 +39,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_contains_float() {
|
fn test_contains_float() {
|
||||||
let arr: Array = vec![
|
let arr: Array = vec![
|
||||||
Dynamic::from(1.5_f64),
|
Dynamic::from(1.5_f64),
|
||||||
|
|
@ -53,7 +53,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_contains_bool() {
|
fn test_contains_bool() {
|
||||||
let arr: Array = vec![Dynamic::from(true), Dynamic::from(false)];
|
let arr: Array = vec![Dynamic::from(true), Dynamic::from(false)];
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_contains_empty_array() {
|
fn test_contains_empty_array() {
|
||||||
let arr = Array::new();
|
let arr = Array::new();
|
||||||
assert!(!array_contains(&arr, &Dynamic::from("anything")));
|
assert!(!array_contains(&arr, &Dynamic::from("anything")));
|
||||||
|
|
@ -71,7 +71,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_items_equal_integers() {
|
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(5_i64)));
|
||||||
assert!(!items_equal(&Dynamic::from(5_i64), &Dynamic::from(6_i64)));
|
assert!(!items_equal(&Dynamic::from(5_i64), &Dynamic::from(6_i64)));
|
||||||
|
|
@ -79,7 +79,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_items_equal_strings() {
|
fn test_items_equal_strings() {
|
||||||
assert!(items_equal(
|
assert!(items_equal(
|
||||||
&Dynamic::from("hello"),
|
&Dynamic::from("hello"),
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -13,7 +13,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_push() {
|
fn test_push() {
|
||||||
let mut arr: Array = vec![Dynamic::from(1), Dynamic::from(2)];
|
let mut arr: Array = vec![Dynamic::from(1), Dynamic::from(2)];
|
||||||
arr.push(Dynamic::from(3));
|
arr.push(Dynamic::from(3));
|
||||||
|
|
@ -23,7 +23,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_pop() {
|
fn test_pop() {
|
||||||
let mut arr: Array = vec![Dynamic::from(1), Dynamic::from(2), Dynamic::from(3)];
|
let mut arr: Array = vec![Dynamic::from(1), Dynamic::from(2), Dynamic::from(3)];
|
||||||
let popped = arr.pop();
|
let popped = arr.pop();
|
||||||
|
|
@ -33,7 +33,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_pop_empty() {
|
fn test_pop_empty() {
|
||||||
let mut arr: Array = vec![];
|
let mut arr: Array = vec![];
|
||||||
let popped = arr.pop();
|
let popped = arr.pop();
|
||||||
|
|
@ -42,7 +42,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_shift() {
|
fn test_shift() {
|
||||||
let mut arr: Array = vec![Dynamic::from(1), Dynamic::from(2), Dynamic::from(3)];
|
let mut arr: Array = vec![Dynamic::from(1), Dynamic::from(2), Dynamic::from(3)];
|
||||||
let shifted = arr.remove(0);
|
let shifted = arr.remove(0);
|
||||||
|
|
@ -53,7 +53,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_unshift() {
|
fn test_unshift() {
|
||||||
let mut arr: Array = vec![Dynamic::from(2), Dynamic::from(3)];
|
let mut arr: Array = vec![Dynamic::from(2), Dynamic::from(3)];
|
||||||
arr.insert(0, Dynamic::from(1));
|
arr.insert(0, Dynamic::from(1));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
fn make_test_array() -> Array {
|
fn make_test_array() -> Array {
|
||||||
vec![
|
vec![
|
||||||
|
|
@ -21,7 +21,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_slice_from_start() {
|
fn test_slice_from_start() {
|
||||||
let arr = make_test_array();
|
let arr = make_test_array();
|
||||||
let result = slice_array(&arr, 2, None);
|
let result = slice_array(&arr, 2, None);
|
||||||
|
|
@ -31,7 +31,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_slice_with_end() {
|
fn test_slice_with_end() {
|
||||||
let arr = make_test_array();
|
let arr = make_test_array();
|
||||||
let result = slice_array(&arr, 1, Some(3));
|
let result = slice_array(&arr, 1, Some(3));
|
||||||
|
|
@ -42,7 +42,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_slice_negative_start() {
|
fn test_slice_negative_start() {
|
||||||
let arr = make_test_array();
|
let arr = make_test_array();
|
||||||
let result = slice_array(&arr, -2, None);
|
let result = slice_array(&arr, -2, None);
|
||||||
|
|
@ -53,7 +53,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_slice_negative_end() {
|
fn test_slice_negative_end() {
|
||||||
let arr = make_test_array();
|
let arr = make_test_array();
|
||||||
let result = slice_array(&arr, 0, Some(-2));
|
let result = slice_array(&arr, 0, Some(-2));
|
||||||
|
|
@ -64,7 +64,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_slice_out_of_bounds() {
|
fn test_slice_out_of_bounds() {
|
||||||
let arr = make_test_array();
|
let arr = make_test_array();
|
||||||
let result = slice_array(&arr, 10, None);
|
let result = slice_array(&arr, 10, None);
|
||||||
|
|
@ -73,7 +73,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_slice_empty_range() {
|
fn test_slice_empty_range() {
|
||||||
let arr = make_test_array();
|
let arr = make_test_array();
|
||||||
let result = slice_array(&arr, 3, Some(2));
|
let result = slice_array(&arr, 3, Some(2));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sort_integers() {
|
fn test_sort_integers() {
|
||||||
let arr: Array = vec![
|
let arr: Array = vec![
|
||||||
Dynamic::from(3),
|
Dynamic::from(3),
|
||||||
|
|
@ -30,7 +30,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sort_strings() {
|
fn test_sort_strings() {
|
||||||
let arr: Array = vec![
|
let arr: Array = vec![
|
||||||
Dynamic::from("banana"),
|
Dynamic::from("banana"),
|
||||||
|
|
@ -45,7 +45,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sort_descending() {
|
fn test_sort_descending() {
|
||||||
let arr: Array = vec![Dynamic::from(1), Dynamic::from(3), Dynamic::from(2)];
|
let arr: Array = vec![Dynamic::from(1), Dynamic::from(3), Dynamic::from(2)];
|
||||||
let sorted = sort_array(arr, true);
|
let sorted = sort_array(arr, true);
|
||||||
|
|
@ -56,7 +56,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_compare_dynamic_numbers() {
|
fn test_compare_dynamic_numbers() {
|
||||||
let a = Dynamic::from(5);
|
let a = Dynamic::from(5);
|
||||||
let b = Dynamic::from(3);
|
let b = Dynamic::from(3);
|
||||||
|
|
@ -65,7 +65,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_compare_dynamic_strings() {
|
fn test_compare_dynamic_strings() {
|
||||||
let a = Dynamic::from("apple");
|
let a = Dynamic::from("apple");
|
||||||
let b = Dynamic::from("banana");
|
let b = Dynamic::from("banana");
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,12 +7,12 @@
|
||||||
|
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_unique_integers() {
|
fn test_unique_integers() {
|
||||||
let mut arr = Array::new();
|
let mut arr = Array::new();
|
||||||
arr.push(Dynamic::from(1_i64));
|
arr.push(Dynamic::from(1_i64));
|
||||||
|
|
@ -29,7 +29,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_unique_strings() {
|
fn test_unique_strings() {
|
||||||
let mut arr = Array::new();
|
let mut arr = Array::new();
|
||||||
arr.push(Dynamic::from("Alice"));
|
arr.push(Dynamic::from("Alice"));
|
||||||
|
|
@ -43,7 +43,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_unique_preserves_order() {
|
fn test_unique_preserves_order() {
|
||||||
let mut arr = Array::new();
|
let mut arr = Array::new();
|
||||||
arr.push(Dynamic::from("C"));
|
arr.push(Dynamic::from("C"));
|
||||||
|
|
@ -61,7 +61,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_unique_empty_array() {
|
fn test_unique_empty_array() {
|
||||||
let arr = Array::new();
|
let arr = Array::new();
|
||||||
let result = unique_array(arr);
|
let result = unique_array(arr);
|
||||||
|
|
@ -70,7 +70,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_unique_single_element() {
|
fn test_unique_single_element() {
|
||||||
let mut arr = Array::new();
|
let mut arr = Array::new();
|
||||||
arr.push(Dynamic::from(42_i64));
|
arr.push(Dynamic::from(42_i64));
|
||||||
|
|
@ -81,7 +81,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_unique_all_same() {
|
fn test_unique_all_same() {
|
||||||
let mut arr = Array::new();
|
let mut arr = Array::new();
|
||||||
arr.push(Dynamic::from(1_i64));
|
arr.push(Dynamic::from(1_i64));
|
||||||
|
|
@ -94,7 +94,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_unique_mixed_types() {
|
fn test_unique_mixed_types() {
|
||||||
let mut arr = Array::new();
|
let mut arr = Array::new();
|
||||||
arr.push(Dynamic::from(1_i64));
|
arr.push(Dynamic::from(1_i64));
|
||||||
|
|
@ -102,7 +102,7 @@ use rhai::Dynamic;
|
||||||
arr.push(Dynamic::from(1_i64));
|
arr.push(Dynamic::from(1_i64));
|
||||||
|
|
||||||
let result = unique_array(arr);
|
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);
|
assert!(result.len() >= 1 && result.len() <= 2);
|
||||||
}
|
}
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_time_string() {
|
fn test_parse_time_string() {
|
||||||
let result = parse_time_string("2024-01-15 14:30");
|
let result = parse_time_string("2024-01-15 14:30");
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_date_string() {
|
fn test_parse_date_string() {
|
||||||
let result = parse_date_string("today");
|
let result = parse_date_string("today");
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_extract_hour() {
|
fn test_extract_hour() {
|
||||||
assert_eq!(extract_hour_from_string("3pm"), Some(15));
|
assert_eq!(extract_hour_from_string("3pm"), Some(15));
|
||||||
assert_eq!(extract_hour_from_string("3 PM"), Some(15));
|
assert_eq!(extract_hour_from_string("3 PM"), Some(15));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_card_style_from_string() {
|
fn test_card_style_from_string() {
|
||||||
assert!(matches!(CardStyle::from("minimal"), CardStyle::Minimal));
|
assert!(matches!(CardStyle::from("minimal"), CardStyle::Minimal));
|
||||||
assert!(matches!(CardStyle::from("VIBRANT"), CardStyle::Vibrant));
|
assert!(matches!(CardStyle::from("VIBRANT"), CardStyle::Vibrant));
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_card_dimensions_for_style() {
|
fn test_card_dimensions_for_style() {
|
||||||
let story_dims = CardDimensions::for_style(&CardStyle::Story);
|
let story_dims = CardDimensions::for_style(&CardStyle::Story);
|
||||||
assert_eq!(story_dims.width, 1080);
|
assert_eq!(story_dims.width, 1080);
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_card_config_default() {
|
fn test_card_config_default() {
|
||||||
let config = CardConfig::default();
|
let config = CardConfig::default();
|
||||||
assert!(matches!(config.style, CardStyle::Modern));
|
assert!(matches!(config.style, CardStyle::Modern));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -8,20 +8,20 @@
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
use rhai::Engine;
|
use rhai::Engine;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_clear_kb_syntax() {
|
fn test_clear_kb_syntax() {
|
||||||
let mut engine = Engine::new();
|
let mut engine = Engine::new();
|
||||||
|
|
||||||
// Test CLEAR_KB with argument
|
|
||||||
assert!(engine
|
assert!(engine
|
||||||
.register_custom_syntax(&["CLEAR_KB", "$expr$"], true, |_, _| Ok(Dynamic::UNIT))
|
.register_custom_syntax(&["CLEAR_KB", "$expr$"], true, |_, _| Ok(Dynamic::UNIT))
|
||||||
.is_ok());
|
.is_ok());
|
||||||
|
|
||||||
// Test CLEAR_KB without argument
|
|
||||||
assert!(engine
|
assert!(engine
|
||||||
.register_custom_syntax(&["CLEAR_KB"], true, |_, _| Ok(Dynamic::UNIT))
|
.register_custom_syntax(&["CLEAR_KB"], true, |_, _| Ok(Dynamic::UNIT))
|
||||||
.is_ok());
|
.is_ok());
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sandbox_config_default() {
|
fn test_sandbox_config_default() {
|
||||||
let config = SandboxConfig::default();
|
let config = SandboxConfig::default();
|
||||||
assert!(config.enabled);
|
assert!(config.enabled);
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_execution_result_success() {
|
fn test_execution_result_success() {
|
||||||
let result = ExecutionResult::success("Hello, World!".to_string(), String::new(), 100);
|
let result = ExecutionResult::success("Hello, World!".to_string(), String::new(), 100);
|
||||||
assert!(result.is_success());
|
assert!(result.is_success());
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_execution_result_error() {
|
fn test_execution_result_error() {
|
||||||
let result = ExecutionResult::error("Something went wrong");
|
let result = ExecutionResult::error("Something went wrong");
|
||||||
assert!(!result.is_success());
|
assert!(!result.is_success());
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_execution_result_timeout() {
|
fn test_execution_result_timeout() {
|
||||||
let result = ExecutionResult::timeout();
|
let result = ExecutionResult::timeout();
|
||||||
assert!(!result.is_success());
|
assert!(!result.is_success());
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_code_language_from_str() {
|
fn test_code_language_from_str() {
|
||||||
assert_eq!(CodeLanguage::from("python"), CodeLanguage::Python);
|
assert_eq!(CodeLanguage::from("python"), CodeLanguage::Python);
|
||||||
assert_eq!(CodeLanguage::from("PYTHON"), CodeLanguage::Python);
|
assert_eq!(CodeLanguage::from("PYTHON"), CodeLanguage::Python);
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_code_language_file_extension() {
|
fn test_code_language_file_extension() {
|
||||||
assert_eq!(CodeLanguage::Python.file_extension(), "py");
|
assert_eq!(CodeLanguage::Python.file_extension(), "py");
|
||||||
assert_eq!(CodeLanguage::JavaScript.file_extension(), "js");
|
assert_eq!(CodeLanguage::JavaScript.file_extension(), "js");
|
||||||
|
|
@ -68,7 +68,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_code_language_interpreter() {
|
fn test_code_language_interpreter() {
|
||||||
assert_eq!(CodeLanguage::Python.interpreter(), "python3");
|
assert_eq!(CodeLanguage::Python.interpreter(), "python3");
|
||||||
assert_eq!(CodeLanguage::JavaScript.interpreter(), "node");
|
assert_eq!(CodeLanguage::JavaScript.interpreter(), "node");
|
||||||
|
|
@ -77,7 +77,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sandbox_runtime_from_str() {
|
fn test_sandbox_runtime_from_str() {
|
||||||
assert_eq!(SandboxRuntime::from("lxc"), SandboxRuntime::LXC);
|
assert_eq!(SandboxRuntime::from("lxc"), SandboxRuntime::LXC);
|
||||||
assert_eq!(SandboxRuntime::from("docker"), SandboxRuntime::Docker);
|
assert_eq!(SandboxRuntime::from("docker"), SandboxRuntime::Docker);
|
||||||
|
|
@ -90,7 +90,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_lxc_config_generation() {
|
fn test_lxc_config_generation() {
|
||||||
let python_config = generate_python_lxc_config();
|
let python_config = generate_python_lxc_config();
|
||||||
assert!(python_config.contains("gb-sandbox-python"));
|
assert!(python_config.contains("gb-sandbox-python"));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -9,9 +9,9 @@
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_module_structure() {
|
fn test_module_structure() {
|
||||||
// This test verifies the module compiles correctly
|
|
||||||
// Actual function tests are in their respective submodules
|
|
||||||
assert!(true);
|
assert!(true);
|
||||||
}
|
}
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_due_date() {
|
fn test_parse_due_date() {
|
||||||
assert!(parse_due_date("tomorrow").is_ok());
|
assert!(parse_due_date("tomorrow").is_ok());
|
||||||
assert!(parse_due_date("+3 days").is_ok());
|
assert!(parse_due_date("+3 days").is_ok());
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_determine_priority() {
|
fn test_determine_priority() {
|
||||||
let tomorrow = Some(Utc::now() + Duration::days(1));
|
let tomorrow = Some(Utc::now() + Duration::days(1));
|
||||||
assert_eq!(determine_priority(tomorrow), "high");
|
assert_eq!(determine_priority(tomorrow), "high");
|
||||||
|
|
|
||||||
|
|
@ -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 botserver::basic::keywords::crm::attendance::create_fallback_tips;
|
||||||
use rhai::Map;
|
use rhai::Map;
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_calculate_lead_score_empty() {
|
fn test_calculate_lead_score_empty() {
|
||||||
let lead_data = Map::new();
|
let lead_data = Map::new();
|
||||||
let score = calculate_lead_score(&lead_data, None);
|
let score = calculate_lead_score(&lead_data, None);
|
||||||
|
|
@ -20,7 +20,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_calculate_lead_score_basic() {
|
fn test_calculate_lead_score_basic() {
|
||||||
let mut lead_data = Map::new();
|
let mut lead_data = Map::new();
|
||||||
lead_data.insert("job_title".into(), Dynamic::from("CEO"));
|
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"));
|
lead_data.insert("email".into(), Dynamic::from("ceo@company.com"));
|
||||||
|
|
||||||
let score = calculate_lead_score(&lead_data, None);
|
let score = calculate_lead_score(&lead_data, None);
|
||||||
assert!(score > 30); // At least CEO bonus
|
assert!(score > 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_calculate_lead_score_with_title() {
|
fn test_calculate_lead_score_with_title() {
|
||||||
let mut lead_data = Map::new();
|
let mut lead_data = Map::new();
|
||||||
lead_data.insert("job_title".into(), Dynamic::from("CTO"));
|
lead_data.insert("job_title".into(), Dynamic::from("CTO"));
|
||||||
|
|
@ -44,7 +44,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_determine_priority() {
|
fn test_determine_priority() {
|
||||||
assert_eq!(determine_priority(95), "CRITICAL");
|
assert_eq!(determine_priority(95), "CRITICAL");
|
||||||
assert_eq!(determine_priority(75), "HIGH");
|
assert_eq!(determine_priority(75), "HIGH");
|
||||||
|
|
@ -55,7 +55,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_score_clamping() {
|
fn test_score_clamping() {
|
||||||
let mut lead_data = Map::new();
|
let mut lead_data = Map::new();
|
||||||
lead_data.insert("budget".into(), Dynamic::from(1000000_i64));
|
lead_data.insert("budget".into(), Dynamic::from(1000000_i64));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sanitize_identifier() {
|
fn test_sanitize_identifier() {
|
||||||
assert_eq!(sanitize_identifier("users"), "users");
|
assert_eq!(sanitize_identifier("users"), "users");
|
||||||
assert_eq!(sanitize_identifier("user_name"), "user_name");
|
assert_eq!(sanitize_identifier("user_name"), "user_name");
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sanitize_sql() {
|
fn test_sanitize_sql() {
|
||||||
assert_eq!(sanitize_sql("hello"), "hello");
|
assert_eq!(sanitize_sql("hello"), "hello");
|
||||||
assert_eq!(sanitize_sql("it's"), "it''s");
|
assert_eq!(sanitize_sql("it's"), "it''s");
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_condition() {
|
fn test_parse_condition() {
|
||||||
let (field, op, value) = parse_condition_internal("status=active").unwrap();
|
let (field, op, value) = parse_condition_internal("status=active").unwrap();
|
||||||
assert_eq!(field, "status");
|
assert_eq!(field, "status");
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_filter_clause() {
|
fn test_parse_filter_clause() {
|
||||||
let clause = parse_filter_clause("name=John").unwrap();
|
let clause = parse_filter_clause("name=John").unwrap();
|
||||||
assert!(clause.contains("name"));
|
assert!(clause.contains("name"));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_dateadd_days() {
|
fn test_dateadd_days() {
|
||||||
assert_eq!(dateadd_impl("2025-01-15", 5, "day"), "2025-01-20");
|
assert_eq!(dateadd_impl("2025-01-15", 5, "day"), "2025-01-20");
|
||||||
assert_eq!(dateadd_impl("2025-01-15", -10, "day"), "2025-01-05");
|
assert_eq!(dateadd_impl("2025-01-15", -10, "day"), "2025-01-05");
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_dateadd_months() {
|
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"), "2025-02-15");
|
||||||
assert_eq!(dateadd_impl("2025-01-15", -1, "month"), "2024-12-15");
|
assert_eq!(dateadd_impl("2025-01-15", -1, "month"), "2024-12-15");
|
||||||
|
|
@ -24,14 +24,14 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_dateadd_years() {
|
fn test_dateadd_years() {
|
||||||
assert_eq!(dateadd_impl("2025-01-15", 1, "year"), "2026-01-15");
|
assert_eq!(dateadd_impl("2025-01-15", 1, "year"), "2026-01-15");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_datediff_days() {
|
fn test_datediff_days() {
|
||||||
assert_eq!(datediff_impl("2025-01-01", "2025-01-15", "day"), 14);
|
assert_eq!(datediff_impl("2025-01-01", "2025-01-15", "day"), 14);
|
||||||
assert_eq!(datediff_impl("2025-01-15", "2025-01-01", "day"), -14);
|
assert_eq!(datediff_impl("2025-01-15", "2025-01-01", "day"), -14);
|
||||||
|
|
@ -39,21 +39,21 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_datediff_months() {
|
fn test_datediff_months() {
|
||||||
assert_eq!(datediff_impl("2025-01-01", "2025-03-01", "month"), 2);
|
assert_eq!(datediff_impl("2025-01-01", "2025-03-01", "month"), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_datediff_years() {
|
fn test_datediff_years() {
|
||||||
assert_eq!(datediff_impl("2024-01-01", "2025-01-01", "year"), 1);
|
assert_eq!(datediff_impl("2024-01-01", "2025-01-01", "year"), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_date() {
|
fn test_parse_date() {
|
||||||
assert!(parse_date("2025-01-15").is_some());
|
assert!(parse_date("2025-01-15").is_some());
|
||||||
assert!(parse_date("15/01/2025").is_some());
|
assert!(parse_date("15/01/2025").is_some());
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_date() {
|
fn test_parse_date() {
|
||||||
let date = parse_date("2025-01-22");
|
let date = parse_date("2025-01-22");
|
||||||
assert!(date.is_some());
|
assert!(date.is_some());
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_datetime() {
|
fn test_parse_datetime() {
|
||||||
let dt = parse_datetime("2025-01-22 14:30:45");
|
let dt = parse_datetime("2025-01-22 14:30:45");
|
||||||
assert!(dt.is_some());
|
assert!(dt.is_some());
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_invalid_date() {
|
fn test_invalid_date() {
|
||||||
let date = parse_date("invalid");
|
let date = parse_date("invalid");
|
||||||
assert!(date.is_none());
|
assert!(date.is_none());
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_create_datetime_map() {
|
fn test_create_datetime_map() {
|
||||||
let now = Local::now();
|
let now = Local::now();
|
||||||
let map = create_datetime_map(now);
|
let map = create_datetime_map(now);
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_year_extraction() {
|
fn test_year_extraction() {
|
||||||
let now = Local::now();
|
let now = Local::now();
|
||||||
let map = create_datetime_map(now);
|
let map = create_datetime_map(now);
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_month_range() {
|
fn test_month_range() {
|
||||||
let now = Local::now();
|
let now = Local::now();
|
||||||
let map = create_datetime_map(now);
|
let map = create_datetime_map(now);
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_hour12_range() {
|
fn test_hour12_range() {
|
||||||
let now = Local::now();
|
let now = Local::now();
|
||||||
let map = create_datetime_map(now);
|
let map = create_datetime_map(now);
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_quarter_calculation() {
|
fn test_quarter_calculation() {
|
||||||
let now = Local::now();
|
let now = Local::now();
|
||||||
let map = create_datetime_map(now);
|
let map = create_datetime_map(now);
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_default_config() {
|
fn test_default_config() {
|
||||||
let config = EpisodicMemoryConfig::default();
|
let config = EpisodicMemoryConfig::default();
|
||||||
assert!(config.enabled);
|
assert!(config.enabled);
|
||||||
|
|
@ -22,7 +22,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_should_summarize() {
|
fn test_should_summarize() {
|
||||||
let manager = EpisodicMemoryManager::new(EpisodicMemoryConfig {
|
let manager = EpisodicMemoryManager::new(EpisodicMemoryConfig {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|
@ -39,20 +39,20 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_extract_json() {
|
fn test_extract_json() {
|
||||||
// Test with code block
|
|
||||||
let response = "Here's the summary:\n```json\n{\"summary\": \"test\"}\n```\n";
|
let response = "Here's the summary:\n```json\n{\"summary\": \"test\"}\n```\n";
|
||||||
assert!(extract_json(response).is_ok());
|
assert!(extract_json(response).is_ok());
|
||||||
|
|
||||||
// Test with raw JSON
|
|
||||||
let response = "The result is {\"summary\": \"test\"}";
|
let response = "The result is {\"summary\": \"test\"}";
|
||||||
assert!(extract_json(response).is_ok());
|
assert!(extract_json(response).is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_generate_summary_prompt() {
|
fn test_generate_summary_prompt() {
|
||||||
let manager = EpisodicMemoryManager::new(EpisodicMemoryConfig::default());
|
let manager = EpisodicMemoryManager::new(EpisodicMemoryConfig::default());
|
||||||
let messages = vec![ConversationMessage {
|
let messages = vec![ConversationMessage {
|
||||||
|
|
@ -69,7 +69,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_summary_response() {
|
fn test_parse_summary_response() {
|
||||||
let manager = EpisodicMemoryManager::new(EpisodicMemoryConfig::default());
|
let manager = EpisodicMemoryManager::new(EpisodicMemoryConfig::default());
|
||||||
let response = r#"{
|
let response = r#"{
|
||||||
|
|
@ -105,7 +105,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_episode_to_dynamic() {
|
fn test_episode_to_dynamic() {
|
||||||
let episode = Episode {
|
let episode = Episode {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -12,7 +12,7 @@ use rhai::Dynamic;
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_error_map() {
|
fn test_error_map() {
|
||||||
use rhai::{Dynamic, Map};
|
use rhai::{Dynamic, Map};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_error_resume_next_flag() {
|
fn test_error_resume_next_flag() {
|
||||||
// Initially should be false
|
|
||||||
assert!(!is_error_resume_next_active());
|
assert!(!is_error_resume_next_active());
|
||||||
|
|
||||||
// Enable it
|
|
||||||
set_error_resume_next(true);
|
set_error_resume_next(true);
|
||||||
assert!(is_error_resume_next_active());
|
assert!(is_error_resume_next_active());
|
||||||
|
|
||||||
// Disable it
|
|
||||||
set_error_resume_next(false);
|
set_error_resume_next(false);
|
||||||
assert!(!is_error_resume_next_active());
|
assert!(!is_error_resume_next_active());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_error_storage() {
|
fn test_error_storage() {
|
||||||
clear_last_error();
|
clear_last_error();
|
||||||
assert!(get_last_error().is_none());
|
assert!(get_last_error().is_none());
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_handle_error_without_resume_next() {
|
fn test_handle_error_without_resume_next() {
|
||||||
set_error_resume_next(false);
|
set_error_resume_next(false);
|
||||||
clear_last_error();
|
clear_last_error();
|
||||||
|
|
@ -50,13 +50,13 @@
|
||||||
Err("Test error".into());
|
Err("Test error".into());
|
||||||
let handled = handle_error(result);
|
let handled = handle_error(result);
|
||||||
|
|
||||||
// Should return error when ON ERROR RESUME NEXT is not active
|
|
||||||
assert!(handled.is_err());
|
assert!(handled.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_handle_error_with_resume_next() {
|
fn test_handle_error_with_resume_next() {
|
||||||
set_error_resume_next(true);
|
set_error_resume_next(true);
|
||||||
clear_last_error();
|
clear_last_error();
|
||||||
|
|
@ -65,10 +65,10 @@
|
||||||
Err("Test error".into());
|
Err("Test error".into());
|
||||||
let handled = handle_error(result);
|
let handled = handle_error(result);
|
||||||
|
|
||||||
// Should return Ok(UNIT) when ON ERROR RESUME NEXT is active
|
|
||||||
assert!(handled.is_ok());
|
assert!(handled.is_ok());
|
||||||
assert_eq!(get_last_error(), Some("Test error".to_string()));
|
assert_eq!(get_last_error(), Some("Test error".to_string()));
|
||||||
|
|
||||||
// Cleanup
|
|
||||||
set_error_resume_next(false);
|
set_error_resume_next(false);
|
||||||
}
|
}
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -9,8 +9,8 @@
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_placeholder() {
|
fn test_placeholder() {
|
||||||
// Placeholder test - actual functionality is in mod.rs
|
|
||||||
assert!(true);
|
assert!(true);
|
||||||
}
|
}
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_dynamic_to_json() {
|
fn test_dynamic_to_json() {
|
||||||
let dynamic = Dynamic::from("hello");
|
let dynamic = Dynamic::from("hello");
|
||||||
let json = dynamic_to_json(&dynamic);
|
let json = dynamic_to_json(&dynamic);
|
||||||
|
|
@ -20,7 +20,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_dynamic_to_file_data() {
|
fn test_dynamic_to_file_data() {
|
||||||
let dynamic = Dynamic::from("test content");
|
let dynamic = Dynamic::from("test content");
|
||||||
let file_data = dynamic_to_file_data(&dynamic);
|
let file_data = dynamic_to_file_data(&dynamic);
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_validate_email() {
|
fn test_validate_email() {
|
||||||
assert!(validate_email("test@example.com").is_valid);
|
assert!(validate_email("test@example.com").is_valid);
|
||||||
assert!(validate_email("user.name+tag@domain.co.uk").is_valid);
|
assert!(validate_email("user.name+tag@domain.co.uk").is_valid);
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_validate_date() {
|
fn test_validate_date() {
|
||||||
assert!(validate_date("25/12/2024").is_valid);
|
assert!(validate_date("25/12/2024").is_valid);
|
||||||
assert!(validate_date("2024-12-25").is_valid);
|
assert!(validate_date("2024-12-25").is_valid);
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_validate_cpf() {
|
fn test_validate_cpf() {
|
||||||
assert!(validate_cpf("529.982.247-25").is_valid);
|
assert!(validate_cpf("529.982.247-25").is_valid);
|
||||||
assert!(validate_cpf("52998224725").is_valid);
|
assert!(validate_cpf("52998224725").is_valid);
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_validate_money() {
|
fn test_validate_money() {
|
||||||
let result = validate_money("R$ 1.234,56");
|
let result = validate_money("R$ 1.234,56");
|
||||||
assert!(result.is_valid);
|
assert!(result.is_valid);
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_validate_boolean() {
|
fn test_validate_boolean() {
|
||||||
assert!(validate_boolean("yes").is_valid);
|
assert!(validate_boolean("yes").is_valid);
|
||||||
assert!(validate_boolean("sim").is_valid);
|
assert!(validate_boolean("sim").is_valid);
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_validate_menu() {
|
fn test_validate_menu() {
|
||||||
let options = vec![
|
let options = vec![
|
||||||
"Apple".to_string(),
|
"Apple".to_string(),
|
||||||
|
|
@ -73,16 +73,16 @@
|
||||||
|
|
||||||
assert!(validate_menu("Apple", &options).is_valid);
|
assert!(validate_menu("Apple", &options).is_valid);
|
||||||
assert!(validate_menu("1", &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);
|
assert!(!validate_menu("Orange", &options).is_valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_validate_credit_card() {
|
fn test_validate_credit_card() {
|
||||||
// Valid Visa test number
|
|
||||||
assert!(validate_credit_card("4111 1111 1111 1111").is_valid);
|
assert!(validate_credit_card("4111 1111 1111 1111").is_valid);
|
||||||
// Invalid (fails Luhn)
|
|
||||||
assert!(!validate_credit_card("1234567890123456").is_valid);
|
assert!(!validate_credit_card("1234567890123456").is_valid);
|
||||||
}
|
}
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_dynamic_to_json_string() {
|
fn test_dynamic_to_json_string() {
|
||||||
let dynamic = Dynamic::from("hello");
|
let dynamic = Dynamic::from("hello");
|
||||||
let json = dynamic_to_json(&dynamic);
|
let json = dynamic_to_json(&dynamic);
|
||||||
|
|
@ -20,7 +20,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_dynamic_to_json_number() {
|
fn test_dynamic_to_json_number() {
|
||||||
let dynamic = Dynamic::from(42_i64);
|
let dynamic = Dynamic::from(42_i64);
|
||||||
let json = dynamic_to_json(&dynamic);
|
let json = dynamic_to_json(&dynamic);
|
||||||
|
|
@ -29,7 +29,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_build_soap_envelope() {
|
fn test_build_soap_envelope() {
|
||||||
let params = json!({"name": "John", "age": 30});
|
let params = json!({"name": "John", "age": 30});
|
||||||
let envelope = build_soap_envelope("GetUser", ¶ms);
|
let envelope = build_soap_envelope("GetUser", ¶ms);
|
||||||
|
|
@ -40,7 +40,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_soap_response() {
|
fn test_parse_soap_response() {
|
||||||
let xml = r#"<?xml version="1.0"?><soap:Envelope><soap:Body><Result>Success</Result></soap:Body></soap:Envelope>"#;
|
let xml = r#"<?xml version="1.0"?><soap:Envelope><soap:Body><Result>Success</Result></soap:Body></soap:Envelope>"#;
|
||||||
let result = parse_soap_response(xml);
|
let result = parse_soap_response(xml);
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_default_config() {
|
fn test_default_config() {
|
||||||
let config = ApprovalConfig::default();
|
let config = ApprovalConfig::default();
|
||||||
assert!(config.enabled);
|
assert!(config.enabled);
|
||||||
|
|
@ -21,7 +21,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_create_request() {
|
fn test_create_request() {
|
||||||
let manager = ApprovalManager::new(ApprovalConfig::default());
|
let manager = ApprovalManager::new(ApprovalConfig::default());
|
||||||
let request = manager.create_request(
|
let request = manager.create_request(
|
||||||
|
|
@ -44,7 +44,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_is_expired() {
|
fn test_is_expired() {
|
||||||
let manager = ApprovalManager::new(ApprovalConfig::default());
|
let manager = ApprovalManager::new(ApprovalConfig::default());
|
||||||
let mut request = manager.create_request(
|
let mut request = manager.create_request(
|
||||||
|
|
@ -56,20 +56,20 @@ use serde_json;
|
||||||
"test@example.com",
|
"test@example.com",
|
||||||
serde_json::json!({}),
|
serde_json::json!({}),
|
||||||
"Test",
|
"Test",
|
||||||
Some(1), // 1 second timeout
|
Some(1),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(!manager.is_expired(&request));
|
assert!(!manager.is_expired(&request));
|
||||||
|
|
||||||
// Manually set expired time
|
|
||||||
request.expires_at = Utc::now() - Duration::seconds(10);
|
request.expires_at = Utc::now() - Duration::seconds(10);
|
||||||
assert!(manager.is_expired(&request));
|
assert!(manager.is_expired(&request));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_process_decision() {
|
fn test_process_decision() {
|
||||||
let manager = ApprovalManager::new(ApprovalConfig::default());
|
let manager = ApprovalManager::new(ApprovalConfig::default());
|
||||||
let mut request = manager.create_request(
|
let mut request = manager.create_request(
|
||||||
|
|
@ -100,7 +100,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_evaluate_condition() {
|
fn test_evaluate_condition() {
|
||||||
let manager = ApprovalManager::new(ApprovalConfig::default());
|
let manager = ApprovalManager::new(ApprovalConfig::default());
|
||||||
let context = serde_json::json!({
|
let context = serde_json::json!({
|
||||||
|
|
@ -121,7 +121,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_handle_timeout_with_default() {
|
fn test_handle_timeout_with_default() {
|
||||||
let manager = ApprovalManager::new(ApprovalConfig::default());
|
let manager = ApprovalManager::new(ApprovalConfig::default());
|
||||||
let mut request = manager.create_request(
|
let mut request = manager.create_request(
|
||||||
|
|
@ -146,7 +146,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_request_to_dynamic() {
|
fn test_request_to_dynamic() {
|
||||||
let manager = ApprovalManager::new(ApprovalConfig::default());
|
let manager = ApprovalManager::new(ApprovalConfig::default());
|
||||||
let request = manager.create_request(
|
let request = manager.create_request(
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_csv_line_simple() {
|
fn test_parse_csv_line_simple() {
|
||||||
let line = "a,b,c";
|
let line = "a,b,c";
|
||||||
let result = parse_csv_line(line);
|
let result = parse_csv_line(line);
|
||||||
|
|
@ -20,7 +20,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_csv_line_quoted() {
|
fn test_parse_csv_line_quoted() {
|
||||||
let line = r#""hello, world",test,"another, value""#;
|
let line = r#""hello, world",test,"another, value""#;
|
||||||
let result = parse_csv_line(line);
|
let result = parse_csv_line(line);
|
||||||
|
|
@ -29,7 +29,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_escape_csv_value() {
|
fn test_escape_csv_value() {
|
||||||
assert_eq!(escape_csv_value("simple"), "simple");
|
assert_eq!(escape_csv_value("simple"), "simple");
|
||||||
assert_eq!(escape_csv_value("with,comma"), "\"with,comma\"");
|
assert_eq!(escape_csv_value("with,comma"), "\"with,comma\"");
|
||||||
|
|
@ -38,7 +38,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_json_to_dynamic_and_back() {
|
fn test_json_to_dynamic_and_back() {
|
||||||
let json = serde_json::json!({
|
let json = serde_json::json!({
|
||||||
"name": "test",
|
"name": "test",
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_collection_stats_serialization() {
|
fn test_collection_stats_serialization() {
|
||||||
let stats = CollectionStats {
|
let stats = CollectionStats {
|
||||||
name: "test_collection".to_string(),
|
name: "test_collection".to_string(),
|
||||||
|
|
@ -31,7 +31,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_kb_statistics_serialization() {
|
fn test_kb_statistics_serialization() {
|
||||||
let stats = KBStatistics {
|
let stats = KBStatistics {
|
||||||
total_collections: 3,
|
total_collections: 3,
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_default_config() {
|
fn test_default_config() {
|
||||||
let config = KnowledgeGraphConfig::default();
|
let config = KnowledgeGraphConfig::default();
|
||||||
assert!(config.enabled);
|
assert!(config.enabled);
|
||||||
|
|
@ -21,7 +21,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_extraction_prompt() {
|
fn test_extraction_prompt() {
|
||||||
let manager = KnowledgeGraphManager::new(KnowledgeGraphConfig::default());
|
let manager = KnowledgeGraphManager::new(KnowledgeGraphConfig::default());
|
||||||
let prompt = manager.generate_extraction_prompt("John works at Acme Corp.");
|
let prompt = manager.generate_extraction_prompt("John works at Acme Corp.");
|
||||||
|
|
@ -31,7 +31,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_extraction_response() {
|
fn test_parse_extraction_response() {
|
||||||
let manager = KnowledgeGraphManager::new(KnowledgeGraphConfig::default());
|
let manager = KnowledgeGraphManager::new(KnowledgeGraphConfig::default());
|
||||||
let response = r#"{
|
let response = r#"{
|
||||||
|
|
@ -64,7 +64,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_entity_to_dynamic() {
|
fn test_entity_to_dynamic() {
|
||||||
let entity = KgEntity {
|
let entity = KgEntity {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
|
|
@ -85,7 +85,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_is_valid_entity_type() {
|
fn test_is_valid_entity_type() {
|
||||||
let manager = KnowledgeGraphManager::new(KnowledgeGraphConfig::default());
|
let manager = KnowledgeGraphManager::new(KnowledgeGraphConfig::default());
|
||||||
assert!(manager.is_valid_entity_type("person"));
|
assert!(manager.is_valid_entity_type("person"));
|
||||||
|
|
@ -96,7 +96,7 @@ use serde_json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_json_to_dynamic() {
|
fn test_json_to_dynamic() {
|
||||||
let json = serde_json::json!({
|
let json = serde_json::json!({
|
||||||
"name": "test",
|
"name": "test",
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -9,9 +9,9 @@
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_module_structure() {
|
fn test_module_structure() {
|
||||||
// This test verifies the module compiles correctly
|
|
||||||
// Actual function tests are in the crm/score_lead.rs module
|
|
||||||
assert!(true);
|
assert!(true);
|
||||||
}
|
}
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_calculate_result_integer() {
|
fn test_parse_calculate_result_integer() {
|
||||||
let result = parse_calculate_result("42").unwrap();
|
let result = parse_calculate_result("42").unwrap();
|
||||||
assert_eq!(result.as_int().unwrap(), 42);
|
assert_eq!(result.as_int().unwrap(), 42);
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_calculate_result_float() {
|
fn test_parse_calculate_result_float() {
|
||||||
let result = parse_calculate_result("3.14").unwrap();
|
let result = parse_calculate_result("3.14").unwrap();
|
||||||
assert!((result.as_float().unwrap() - 3.14).abs() < 0.001);
|
assert!((result.as_float().unwrap() - 3.14).abs() < 0.001);
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_calculate_result_boolean() {
|
fn test_parse_calculate_result_boolean() {
|
||||||
let result = parse_calculate_result("true").unwrap();
|
let result = parse_calculate_result("true").unwrap();
|
||||||
assert!(result.as_bool().unwrap());
|
assert!(result.as_bool().unwrap());
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_build_translate_prompt() {
|
fn test_build_translate_prompt() {
|
||||||
let prompt = build_translate_prompt("Hello", "Spanish");
|
let prompt = build_translate_prompt("Hello", "Spanish");
|
||||||
assert!(prompt.contains("Hello"));
|
assert!(prompt.contains("Hello"));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_abs_positive() {
|
fn test_abs_positive() {
|
||||||
assert_eq!(42_i64.abs(), 42);
|
assert_eq!(42_i64.abs(), 42);
|
||||||
assert_eq!(3.14_f64.abs(), 3.14);
|
assert_eq!(3.14_f64.abs(), 3.14);
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_abs_negative() {
|
fn test_abs_negative() {
|
||||||
assert_eq!((-42_i64).abs(), 42);
|
assert_eq!((-42_i64).abs(), 42);
|
||||||
assert_eq!((-3.14_f64).abs(), 3.14);
|
assert_eq!((-3.14_f64).abs(), 3.14);
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_abs_zero() {
|
fn test_abs_zero() {
|
||||||
assert_eq!(0_i64.abs(), 0);
|
assert_eq!(0_i64.abs(), 0);
|
||||||
assert_eq!(0.0_f64.abs(), 0.0);
|
assert_eq!(0.0_f64.abs(), 0.0);
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -13,7 +13,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sum() {
|
fn test_sum() {
|
||||||
let arr: Vec<Dynamic> = vec![
|
let arr: Vec<Dynamic> = vec![
|
||||||
Dynamic::from(10_i64),
|
Dynamic::from(10_i64),
|
||||||
|
|
@ -29,7 +29,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_avg() {
|
fn test_avg() {
|
||||||
let arr: Vec<f64> = vec![10.0, 20.0, 30.0];
|
let arr: Vec<f64> = vec![10.0, 20.0, 30.0];
|
||||||
let sum: f64 = arr.iter().sum();
|
let sum: f64 = arr.iter().sum();
|
||||||
|
|
@ -39,7 +39,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_empty_array() {
|
fn test_empty_array() {
|
||||||
let arr: Vec<f64> = vec![];
|
let arr: Vec<f64> = vec![];
|
||||||
let result = if arr.is_empty() { 0.0 } else { arr.iter().sum::<f64>() / arr.len() as f64 };
|
let result = if arr.is_empty() { 0.0 } else { arr.iter().sum::<f64>() / arr.len() as f64 };
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_int() {
|
fn test_int() {
|
||||||
assert_eq!(3.9_f64.trunc() as i64, 3);
|
assert_eq!(3.9_f64.trunc() as i64, 3);
|
||||||
assert_eq!((-3.9_f64).trunc() as i64, -3);
|
assert_eq!((-3.9_f64).trunc() as i64, -3);
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_floor_ceil() {
|
fn test_floor_ceil() {
|
||||||
assert_eq!(3.7_f64.floor() as i64, 3);
|
assert_eq!(3.7_f64.floor() as i64, 3);
|
||||||
assert_eq!(3.2_f64.ceil() as i64, 4);
|
assert_eq!(3.2_f64.ceil() as i64, 4);
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_minmax() {
|
fn test_minmax() {
|
||||||
assert_eq!(10_i64.max(5), 10);
|
assert_eq!(10_i64.max(5), 10);
|
||||||
assert_eq!(10_i64.min(5), 5);
|
assert_eq!(10_i64.min(5), 5);
|
||||||
|
|
@ -33,14 +33,14 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_mod() {
|
fn test_mod() {
|
||||||
assert_eq!(17 % 5, 2);
|
assert_eq!(17 % 5, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sgn() {
|
fn test_sgn() {
|
||||||
assert_eq!((-5_i64).signum(), -1);
|
assert_eq!((-5_i64).signum(), -1);
|
||||||
assert_eq!(5_i64.signum(), 1);
|
assert_eq!(5_i64.signum(), 1);
|
||||||
|
|
@ -49,14 +49,14 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sqrt() {
|
fn test_sqrt() {
|
||||||
assert!((16_f64.sqrt() - 4.0).abs() < 0.0001);
|
assert!((16_f64.sqrt() - 4.0).abs() < 0.0001);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_pow() {
|
fn test_pow() {
|
||||||
assert!((2_f64.powf(8.0) - 256.0).abs() < 0.0001);
|
assert!((2_f64.powf(8.0) - 256.0).abs() < 0.0001);
|
||||||
}
|
}
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_max_values() {
|
fn test_max_values() {
|
||||||
assert_eq!(10_i64.max(5), 10);
|
assert_eq!(10_i64.max(5), 10);
|
||||||
assert_eq!(3.5_f64.max(7.2), 7.2);
|
assert_eq!(3.5_f64.max(7.2), 7.2);
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_min_values() {
|
fn test_min_values() {
|
||||||
assert_eq!(10_i64.min(5), 5);
|
assert_eq!(10_i64.min(5), 5);
|
||||||
assert_eq!(3.5_f64.min(7.2), 3.5);
|
assert_eq!(3.5_f64.min(7.2), 3.5);
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_mod() {
|
fn test_mod() {
|
||||||
assert_eq!(17 % 5, 2);
|
assert_eq!(17 % 5, 2);
|
||||||
assert_eq!(10 % 3, 1);
|
assert_eq!(10 % 3, 1);
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_round_basic() {
|
fn test_round_basic() {
|
||||||
assert_eq!(3.7_f64.round() as i64, 4);
|
assert_eq!(3.7_f64.round() as i64, 4);
|
||||||
assert_eq!(3.2_f64.round() as i64, 3);
|
assert_eq!(3.2_f64.round() as i64, 3);
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_round_decimals() {
|
fn test_round_decimals() {
|
||||||
let n = 2.71828_f64;
|
let n = 2.71828_f64;
|
||||||
let decimals = 2;
|
let decimals = 2;
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -9,35 +9,35 @@
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_sin() {
|
fn test_sin() {
|
||||||
assert!((0.0_f64.sin() - 0.0).abs() < 0.0001);
|
assert!((0.0_f64.sin() - 0.0).abs() < 0.0001);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_cos() {
|
fn test_cos() {
|
||||||
assert!((0.0_f64.cos() - 1.0).abs() < 0.0001);
|
assert!((0.0_f64.cos() - 1.0).abs() < 0.0001);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_log() {
|
fn test_log() {
|
||||||
assert!((100.0_f64.log10() - 2.0).abs() < 0.0001);
|
assert!((100.0_f64.log10() - 2.0).abs() < 0.0001);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_exp() {
|
fn test_exp() {
|
||||||
assert!((0.0_f64.exp() - 1.0).abs() < 0.0001);
|
assert!((0.0_f64.exp() - 1.0).abs() < 0.0001);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_pi() {
|
fn test_pi() {
|
||||||
assert!(std::f64::consts::PI > 3.14);
|
assert!(std::f64::consts::PI > 3.14);
|
||||||
assert!(std::f64::consts::PI < 3.15);
|
assert!(std::f64::consts::PI < 3.15);
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_csv_columns() {
|
fn test_parse_csv_columns() {
|
||||||
let loader = McpCsvLoader::new("./work", "test");
|
let loader = McpCsvLoader::new("./work", "test");
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_args() {
|
fn test_parse_args() {
|
||||||
let loader = McpCsvLoader::new("./work", "test");
|
let loader = McpCsvLoader::new("./work", "test");
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_infer_server_type() {
|
fn test_infer_server_type() {
|
||||||
let loader = McpCsvLoader::new("./work", "test");
|
let loader = McpCsvLoader::new("./work", "test");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_send_template_valid_email() {
|
fn test_send_template_valid_email() {
|
||||||
let result = send_template_message("welcome", "user@example.com", "email", None);
|
let result = send_template_message("welcome", "user@example.com", "email", None);
|
||||||
assert!(result.get("success").unwrap().as_bool().unwrap());
|
assert!(result.get("success").unwrap().as_bool().unwrap());
|
||||||
|
|
@ -19,7 +19,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_send_template_invalid_email() {
|
fn test_send_template_invalid_email() {
|
||||||
let result = send_template_message("welcome", "invalid-email", "email", None);
|
let result = send_template_message("welcome", "invalid-email", "email", None);
|
||||||
assert!(!result.get("success").unwrap().as_bool().unwrap());
|
assert!(!result.get("success").unwrap().as_bool().unwrap());
|
||||||
|
|
@ -27,7 +27,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_send_template_invalid_channel() {
|
fn test_send_template_invalid_channel() {
|
||||||
let result = send_template_message("welcome", "user@example.com", "invalid", None);
|
let result = send_template_message("welcome", "user@example.com", "invalid", None);
|
||||||
assert!(!result.get("success").unwrap().as_bool().unwrap());
|
assert!(!result.get("success").unwrap().as_bool().unwrap());
|
||||||
|
|
@ -35,7 +35,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_send_template_batch() {
|
fn test_send_template_batch() {
|
||||||
let mut recipients = Array::new();
|
let mut recipients = Array::new();
|
||||||
recipients.push(Dynamic::from("user1@example.com"));
|
recipients.push(Dynamic::from("user1@example.com"));
|
||||||
|
|
@ -48,7 +48,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_create_template() {
|
fn test_create_template() {
|
||||||
let result = create_message_template("test", "email", Some("Subject"), "Hello {{name}}!");
|
let result = create_message_template("test", "email", Some("Subject"), "Hello {{name}}!");
|
||||||
assert!(result.get("success").unwrap().as_bool().unwrap());
|
assert!(result.get("success").unwrap().as_bool().unwrap());
|
||||||
|
|
@ -56,7 +56,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_create_template_empty_name() {
|
fn test_create_template_empty_name() {
|
||||||
let result = create_message_template("", "email", None, "Content");
|
let result = create_message_template("", "email", None, "Content");
|
||||||
assert!(!result.get("success").unwrap().as_bool().unwrap());
|
assert!(!result.get("success").unwrap().as_bool().unwrap());
|
||||||
|
|
@ -64,7 +64,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_extract_template_variables() {
|
fn test_extract_template_variables() {
|
||||||
let content = "Hello {{name}}, your order {{order_id}} is ready!";
|
let content = "Hello {{name}}, your order {{order_id}} is ready!";
|
||||||
let vars = extract_template_variables(content);
|
let vars = extract_template_variables(content);
|
||||||
|
|
@ -73,7 +73,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_extract_template_variables_empty() {
|
fn test_extract_template_variables_empty() {
|
||||||
let content = "Hello, no variables here!";
|
let content = "Hello, no variables here!";
|
||||||
let vars = extract_template_variables(content);
|
let vars = extract_template_variables(content);
|
||||||
|
|
@ -82,7 +82,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_generate_message_id() {
|
fn test_generate_message_id() {
|
||||||
let id = generate_message_id();
|
let id = generate_message_id();
|
||||||
assert!(id.starts_with("msg_"));
|
assert!(id.starts_with("msg_"));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_model_router_new() {
|
fn test_model_router_new() {
|
||||||
let router = ModelRouter::new();
|
let router = ModelRouter::new();
|
||||||
assert_eq!(router.default_model, "default");
|
assert_eq!(router.default_model, "default");
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_auto_routing_code() {
|
fn test_auto_routing_code() {
|
||||||
let mut router = ModelRouter::new();
|
let mut router = ModelRouter::new();
|
||||||
router.models.insert(
|
router.models.insert(
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_auto_routing_quality() {
|
fn test_auto_routing_quality() {
|
||||||
let mut router = ModelRouter::new();
|
let mut router = ModelRouter::new();
|
||||||
router.models.insert(
|
router.models.insert(
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_auto_routing_fast() {
|
fn test_auto_routing_fast() {
|
||||||
let mut router = ModelRouter::new();
|
let mut router = ModelRouter::new();
|
||||||
router.models.insert(
|
router.models.insert(
|
||||||
|
|
@ -85,7 +85,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_routing_strategy_default() {
|
fn test_routing_strategy_default() {
|
||||||
let strategy = RoutingStrategy::default();
|
let strategy = RoutingStrategy::default();
|
||||||
assert_eq!(strategy, RoutingStrategy::Manual);
|
assert_eq!(strategy, RoutingStrategy::Manual);
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_folder_path_account() {
|
fn test_parse_folder_path_account() {
|
||||||
let (provider, email, path) =
|
let (provider, email, path) =
|
||||||
parse_folder_path("account://user@gmail.com/Documents/invoices");
|
parse_folder_path("account://user@gmail.com/Documents/invoices");
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_folder_path_gdrive() {
|
fn test_parse_folder_path_gdrive() {
|
||||||
let (provider, email, path) = parse_folder_path("gdrive:///shared/reports");
|
let (provider, email, path) = parse_folder_path("gdrive:///shared/reports");
|
||||||
assert_eq!(provider, FolderProvider::GDrive);
|
assert_eq!(provider, FolderProvider::GDrive);
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_folder_path_onedrive() {
|
fn test_parse_folder_path_onedrive() {
|
||||||
let (provider, email, path) = parse_folder_path("onedrive:///business/docs");
|
let (provider, email, path) = parse_folder_path("onedrive:///business/docs");
|
||||||
assert_eq!(provider, FolderProvider::OneDrive);
|
assert_eq!(provider, FolderProvider::OneDrive);
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_folder_path_dropbox() {
|
fn test_parse_folder_path_dropbox() {
|
||||||
let (provider, email, path) = parse_folder_path("dropbox:///team/assets");
|
let (provider, email, path) = parse_folder_path("dropbox:///team/assets");
|
||||||
assert_eq!(provider, FolderProvider::Dropbox);
|
assert_eq!(provider, FolderProvider::Dropbox);
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_folder_path_local() {
|
fn test_parse_folder_path_local() {
|
||||||
let (provider, email, path) = parse_folder_path("/home/user/documents");
|
let (provider, email, path) = parse_folder_path("/home/user/documents");
|
||||||
assert_eq!(provider, FolderProvider::Local);
|
assert_eq!(provider, FolderProvider::Local);
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_is_cloud_path() {
|
fn test_is_cloud_path() {
|
||||||
assert!(is_cloud_path("account://user@gmail.com/docs"));
|
assert!(is_cloud_path("account://user@gmail.com/docs"));
|
||||||
assert!(is_cloud_path("gdrive:///shared"));
|
assert!(is_cloud_path("gdrive:///shared"));
|
||||||
|
|
@ -71,7 +71,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_folder_provider_from_str() {
|
fn test_folder_provider_from_str() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
FolderProvider::from_str("gdrive"),
|
FolderProvider::from_str("gdrive"),
|
||||||
|
|
@ -114,7 +114,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_change_event_type_from_str() {
|
fn test_change_event_type_from_str() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ChangeEventType::from_str("create"),
|
ChangeEventType::from_str("create"),
|
||||||
|
|
@ -153,7 +153,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sanitize_path() {
|
fn test_sanitize_path() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
sanitize_path_for_filename("/home/user/docs"),
|
sanitize_path_for_filename("/home/user/docs"),
|
||||||
|
|
@ -171,7 +171,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_folder_monitor_struct() {
|
fn test_folder_monitor_struct() {
|
||||||
let monitor = FolderMonitor {
|
let monitor = FolderMonitor {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
|
|
@ -194,7 +194,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_folder_change_event_struct() {
|
fn test_folder_change_event_struct() {
|
||||||
let event = FolderChangeEvent {
|
let event = FolderChangeEvent {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
|
|
@ -214,7 +214,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_detect_provider_from_email() {
|
fn test_detect_provider_from_email() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
detect_provider_from_email("user@gmail.com"),
|
detect_provider_from_email("user@gmail.com"),
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_email_monitor_struct() {
|
fn test_email_monitor_struct() {
|
||||||
let monitor = EmailMonitor {
|
let monitor = EmailMonitor {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_email_monitor_with_filters() {
|
fn test_email_monitor_with_filters() {
|
||||||
let monitor = EmailMonitor {
|
let monitor = EmailMonitor {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_email_attachment_struct() {
|
fn test_email_attachment_struct() {
|
||||||
let attachment = EmailAttachment {
|
let attachment = EmailAttachment {
|
||||||
filename: "document.pdf".to_string(),
|
filename: "document.pdf".to_string(),
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_email_received_event_struct() {
|
fn test_email_received_event_struct() {
|
||||||
let event = EmailReceivedEvent {
|
let event = EmailReceivedEvent {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
|
|
@ -89,7 +89,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_email_path_basic() {
|
fn test_parse_email_path_basic() {
|
||||||
let result = parse_email_path("email://user@gmail.com");
|
let result = parse_email_path("email://user@gmail.com");
|
||||||
assert!(result.is_some());
|
assert!(result.is_some());
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_email_path_with_folder() {
|
fn test_parse_email_path_with_folder() {
|
||||||
let result = parse_email_path("email://user@gmail.com/INBOX");
|
let result = parse_email_path("email://user@gmail.com/INBOX");
|
||||||
assert!(result.is_some());
|
assert!(result.is_some());
|
||||||
|
|
@ -111,7 +111,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_email_path_invalid() {
|
fn test_parse_email_path_invalid() {
|
||||||
assert!(parse_email_path("user@gmail.com").is_none());
|
assert!(parse_email_path("user@gmail.com").is_none());
|
||||||
assert!(parse_email_path("mailto:user@gmail.com").is_none());
|
assert!(parse_email_path("mailto:user@gmail.com").is_none());
|
||||||
|
|
@ -120,7 +120,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_is_email_path() {
|
fn test_is_email_path() {
|
||||||
assert!(is_email_path("email://user@gmail.com"));
|
assert!(is_email_path("email://user@gmail.com"));
|
||||||
assert!(is_email_path("email://user@company.com/INBOX"));
|
assert!(is_email_path("email://user@company.com/INBOX"));
|
||||||
|
|
@ -131,7 +131,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sanitize_email_for_filename() {
|
fn test_sanitize_email_for_filename() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
sanitize_email_for_filename("user@gmail.com"),
|
sanitize_email_for_filename("user@gmail.com"),
|
||||||
|
|
@ -149,7 +149,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_email_event_without_attachments() {
|
fn test_email_event_without_attachments() {
|
||||||
let event = EmailReceivedEvent {
|
let event = EmailReceivedEvent {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
|
|
@ -170,7 +170,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_multiple_to_addresses() {
|
fn test_multiple_to_addresses() {
|
||||||
let event = EmailReceivedEvent {
|
let event = EmailReceivedEvent {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
|
|
@ -196,7 +196,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_multiple_attachments() {
|
fn test_multiple_attachments() {
|
||||||
let attachments = vec![
|
let attachments = vec![
|
||||||
EmailAttachment {
|
EmailAttachment {
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_content_type_from_extension() {
|
fn test_content_type_from_extension() {
|
||||||
assert_eq!(ContentType::from_extension("mp4"), ContentType::Video);
|
assert_eq!(ContentType::from_extension("mp4"), ContentType::Video);
|
||||||
assert_eq!(ContentType::from_extension("MP3"), ContentType::Audio);
|
assert_eq!(ContentType::from_extension("MP3"), ContentType::Audio);
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_content_type_from_mime() {
|
fn test_content_type_from_mime() {
|
||||||
assert_eq!(ContentType::from_mime("video/mp4"), ContentType::Video);
|
assert_eq!(ContentType::from_mime("video/mp4"), ContentType::Video);
|
||||||
assert_eq!(ContentType::from_mime("audio/mpeg"), ContentType::Audio);
|
assert_eq!(ContentType::from_mime("audio/mpeg"), ContentType::Audio);
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_play_options_from_string() {
|
fn test_play_options_from_string() {
|
||||||
let opts = PlayOptions::from_string("autoplay,loop,muted");
|
let opts = PlayOptions::from_string("autoplay,loop,muted");
|
||||||
assert!(opts.autoplay);
|
assert!(opts.autoplay);
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_detect_content_type() {
|
fn test_detect_content_type() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
detect_content_type("https://youtube.com/watch?v=123"),
|
detect_content_type("https://youtube.com/watch?v=123"),
|
||||||
|
|
@ -85,7 +85,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_extract_title_from_source() {
|
fn test_extract_title_from_source() {
|
||||||
assert_eq!(extract_title_from_source("documents/report.pdf"), "report");
|
assert_eq!(extract_title_from_source("documents/report.pdf"), "report");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_player_component() {
|
fn test_player_component() {
|
||||||
assert_eq!(ContentType::Video.player_component(), "video-player");
|
assert_eq!(ContentType::Video.player_component(), "video-player");
|
||||||
assert_eq!(ContentType::Audio.player_component(), "audio-player");
|
assert_eq!(ContentType::Audio.player_component(), "audio-player");
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
fn setup() {
|
fn setup() {
|
||||||
clear_procedures();
|
clear_procedures();
|
||||||
|
|
@ -15,7 +15,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_preprocess_sub() {
|
fn test_preprocess_sub() {
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
|
|
@ -29,13 +29,13 @@ y = 2
|
||||||
|
|
||||||
let result = preprocess_subs(input);
|
let result = preprocess_subs(input);
|
||||||
|
|
||||||
// SUB should be extracted
|
|
||||||
assert!(!result.contains("SUB MySub"));
|
assert!(!result.contains("SUB MySub"));
|
||||||
assert!(!result.contains("END SUB"));
|
assert!(!result.contains("END SUB"));
|
||||||
assert!(result.contains("x = 1"));
|
assert!(result.contains("x = 1"));
|
||||||
assert!(result.contains("y = 2"));
|
assert!(result.contains("y = 2"));
|
||||||
|
|
||||||
// Procedure should be registered
|
|
||||||
assert!(has_procedure("MYSUB"));
|
assert!(has_procedure("MYSUB"));
|
||||||
let proc = get_procedure("MYSUB").unwrap();
|
let proc = get_procedure("MYSUB").unwrap();
|
||||||
assert_eq!(proc.params.len(), 2);
|
assert_eq!(proc.params.len(), 2);
|
||||||
|
|
@ -44,7 +44,7 @@ y = 2
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_preprocess_function() {
|
fn test_preprocess_function() {
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
|
|
@ -57,12 +57,12 @@ result = Add(1, 2)
|
||||||
|
|
||||||
let result = preprocess_functions(input);
|
let result = preprocess_functions(input);
|
||||||
|
|
||||||
// FUNCTION should be extracted
|
|
||||||
assert!(!result.contains("FUNCTION Add"));
|
assert!(!result.contains("FUNCTION Add"));
|
||||||
assert!(!result.contains("END FUNCTION"));
|
assert!(!result.contains("END FUNCTION"));
|
||||||
assert!(result.contains("result = Add(1, 2)"));
|
assert!(result.contains("result = Add(1, 2)"));
|
||||||
|
|
||||||
// Procedure should be registered
|
|
||||||
assert!(has_procedure("ADD"));
|
assert!(has_procedure("ADD"));
|
||||||
let proc = get_procedure("ADD").unwrap();
|
let proc = get_procedure("ADD").unwrap();
|
||||||
assert!(proc.is_function);
|
assert!(proc.is_function);
|
||||||
|
|
@ -70,7 +70,7 @@ result = Add(1, 2)
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_preprocess_sub_no_params() {
|
fn test_preprocess_sub_no_params() {
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
|
|
@ -89,11 +89,11 @@ END SUB
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_preprocess_call() {
|
fn test_preprocess_call() {
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
// First register a SUB
|
|
||||||
let sub_input = r#"
|
let sub_input = r#"
|
||||||
SUB Greet(name)
|
SUB Greet(name)
|
||||||
TALK "Hello " + name
|
TALK "Hello " + name
|
||||||
|
|
@ -101,18 +101,18 @@ END SUB
|
||||||
"#;
|
"#;
|
||||||
preprocess_subs(sub_input);
|
preprocess_subs(sub_input);
|
||||||
|
|
||||||
// Then preprocess CALL
|
|
||||||
let call_input = "CALL Greet(\"World\")";
|
let call_input = "CALL Greet(\"World\")";
|
||||||
let result = preprocess_calls(call_input);
|
let result = preprocess_calls(call_input);
|
||||||
|
|
||||||
// Should contain parameter assignment and body
|
|
||||||
assert!(result.contains("let name = \"World\""));
|
assert!(result.contains("let name = \"World\""));
|
||||||
assert!(result.contains("TALK \"Hello \" + name"));
|
assert!(result.contains("TALK \"Hello \" + name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_eval_bool_condition() {
|
fn test_eval_bool_condition() {
|
||||||
assert!(eval_bool_condition(&Dynamic::from(true)));
|
assert!(eval_bool_condition(&Dynamic::from(true)));
|
||||||
assert!(!eval_bool_condition(&Dynamic::from(false)));
|
assert!(!eval_bool_condition(&Dynamic::from(false)));
|
||||||
|
|
@ -128,7 +128,7 @@ END SUB
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_clear_procedures() {
|
fn test_clear_procedures() {
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
|
|
@ -144,7 +144,7 @@ END SUB
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_full_pipeline() {
|
fn test_full_pipeline() {
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
|
|
@ -165,17 +165,17 @@ total = Calculate(5, 3)
|
||||||
|
|
||||||
let result = preprocess_procedures(input);
|
let result = preprocess_procedures(input);
|
||||||
|
|
||||||
// Should have inlined the CALL
|
|
||||||
assert!(result.contains("let name = \"User\""));
|
assert!(result.contains("let name = \"User\""));
|
||||||
assert!(result.contains("let greeting = \"Hello\""));
|
assert!(result.contains("let greeting = \"Hello\""));
|
||||||
|
|
||||||
// Original definitions should be gone
|
|
||||||
assert!(!result.contains("SUB SendGreeting"));
|
assert!(!result.contains("SUB SendGreeting"));
|
||||||
assert!(!result.contains("END SUB"));
|
assert!(!result.contains("END SUB"));
|
||||||
assert!(!result.contains("FUNCTION Calculate"));
|
assert!(!result.contains("FUNCTION Calculate"));
|
||||||
assert!(!result.contains("END FUNCTION"));
|
assert!(!result.contains("END FUNCTION"));
|
||||||
|
|
||||||
// Both should be registered
|
|
||||||
assert!(has_procedure("SENDGREETING"));
|
assert!(has_procedure("SENDGREETING"));
|
||||||
assert!(has_procedure("CALCULATE"));
|
assert!(has_procedure("CALCULATE"));
|
||||||
}
|
}
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_qr_code_generation() {
|
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");
|
let result = QrCode::new(b"https://example.com");
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_qr_code_with_unicode() {
|
fn test_qr_code_with_unicode() {
|
||||||
let result = QrCode::new("Hello 世界 🌍".as_bytes());
|
let result = QrCode::new("Hello 世界 🌍".as_bytes());
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_qr_code_long_data() {
|
fn test_qr_code_long_data() {
|
||||||
let long_data = "A".repeat(1000);
|
let long_data = "A".repeat(1000);
|
||||||
let result = QrCode::new(long_data.as_bytes());
|
let result = QrCode::new(long_data.as_bytes());
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_qr_code_url() {
|
fn test_qr_code_url() {
|
||||||
let url = "https://example.com/path?param=value&other=123";
|
let url = "https://example.com/path?param=value&other=123";
|
||||||
let result = QrCode::new(url.as_bytes());
|
let result = QrCode::new(url.as_bytes());
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_qr_code_json() {
|
fn test_qr_code_json() {
|
||||||
let json = r#"{"id": 123, "name": "Test", "active": true}"#;
|
let json = r#"{"id": 123, "name": "Test", "active": true}"#;
|
||||||
let result = QrCode::new(json.as_bytes());
|
let result = QrCode::new(json.as_bytes());
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_duration() {
|
fn test_parse_duration() {
|
||||||
// Test various duration formats
|
|
||||||
assert!(parse_duration("30 days").is_ok());
|
assert!(parse_duration("30 days").is_ok());
|
||||||
assert!(parse_duration("1 hour").is_ok());
|
assert!(parse_duration("1 hour").is_ok());
|
||||||
assert!(parse_duration("forever").is_ok());
|
assert!(parse_duration("forever").is_ok());
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_clean_value_for_type() {
|
fn test_clean_value_for_type() {
|
||||||
assert_eq!(clean_value_for_type(&json!("test"), "text"), json!("test"));
|
assert_eq!(clean_value_for_type(&json!("test"), "text"), json!("test"));
|
||||||
assert_eq!(clean_value_for_type(&json!("42"), "integer"), json!(42));
|
assert_eq!(clean_value_for_type(&json!("42"), "integer"), json!(42));
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_get_default_schema() {
|
fn test_get_default_schema() {
|
||||||
let leads_schema = get_default_schema("leads");
|
let leads_schema = get_default_schema("leads");
|
||||||
assert!(leads_schema.is_array());
|
assert!(leads_schema.is_array());
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_apply_template_variables() {
|
fn test_apply_template_variables() {
|
||||||
let template = "Hello {{name}}, your order {{order_id}} is ready!";
|
let template = "Hello {{name}}, your order {{order_id}} is ready!";
|
||||||
let vars = json!({
|
let vars = json!({
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_extract_template_subject() {
|
fn test_extract_template_subject() {
|
||||||
let content = "Subject: Welcome to our service\n\nHello there!";
|
let content = "Subject: Welcome to our service\n\nHello there!";
|
||||||
let subject = extract_template_subject(content);
|
let subject = extract_template_subject(content);
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -9,9 +9,9 @@
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_module_structure() {
|
fn test_module_structure() {
|
||||||
// This test verifies the module compiles correctly
|
|
||||||
// Actual function tests are in the messaging/send_template.rs module
|
|
||||||
assert!(true);
|
assert!(true);
|
||||||
}
|
}
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_every_minute() {
|
fn test_every_minute() {
|
||||||
assert_eq!(parse_natural_schedule("every minute").unwrap(), "* * * * *");
|
assert_eq!(parse_natural_schedule("every minute").unwrap(), "* * * * *");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_every_n_minutes() {
|
fn test_every_n_minutes() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_natural_schedule("every 5 minutes").unwrap(),
|
parse_natural_schedule("every 5 minutes").unwrap(),
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_every_hour() {
|
fn test_every_hour() {
|
||||||
assert_eq!(parse_natural_schedule("every hour").unwrap(), "0 * * * *");
|
assert_eq!(parse_natural_schedule("every hour").unwrap(), "0 * * * *");
|
||||||
assert_eq!(parse_natural_schedule("hourly").unwrap(), "0 * * * *");
|
assert_eq!(parse_natural_schedule("hourly").unwrap(), "0 * * * *");
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_every_n_hours() {
|
fn test_every_n_hours() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_natural_schedule("every 2 hours").unwrap(),
|
parse_natural_schedule("every 2 hours").unwrap(),
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_every_day() {
|
fn test_every_day() {
|
||||||
assert_eq!(parse_natural_schedule("every day").unwrap(), "0 0 * * *");
|
assert_eq!(parse_natural_schedule("every day").unwrap(), "0 0 * * *");
|
||||||
assert_eq!(parse_natural_schedule("daily").unwrap(), "0 0 * * *");
|
assert_eq!(parse_natural_schedule("daily").unwrap(), "0 0 * * *");
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_every_week() {
|
fn test_every_week() {
|
||||||
assert_eq!(parse_natural_schedule("every week").unwrap(), "0 0 * * 0");
|
assert_eq!(parse_natural_schedule("every week").unwrap(), "0 0 * * 0");
|
||||||
assert_eq!(parse_natural_schedule("weekly").unwrap(), "0 0 * * 0");
|
assert_eq!(parse_natural_schedule("weekly").unwrap(), "0 0 * * 0");
|
||||||
|
|
@ -71,7 +71,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_every_month() {
|
fn test_every_month() {
|
||||||
assert_eq!(parse_natural_schedule("every month").unwrap(), "0 0 1 * *");
|
assert_eq!(parse_natural_schedule("every month").unwrap(), "0 0 1 * *");
|
||||||
assert_eq!(parse_natural_schedule("monthly").unwrap(), "0 0 1 * *");
|
assert_eq!(parse_natural_schedule("monthly").unwrap(), "0 0 1 * *");
|
||||||
|
|
@ -79,7 +79,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_at_time() {
|
fn test_at_time() {
|
||||||
assert_eq!(parse_natural_schedule("at 9am").unwrap(), "0 9 * * *");
|
assert_eq!(parse_natural_schedule("at 9am").unwrap(), "0 9 * * *");
|
||||||
assert_eq!(parse_natural_schedule("at 9:30am").unwrap(), "30 9 * * *");
|
assert_eq!(parse_natural_schedule("at 9:30am").unwrap(), "30 9 * * *");
|
||||||
|
|
@ -91,7 +91,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_day_of_week() {
|
fn test_day_of_week() {
|
||||||
assert_eq!(parse_natural_schedule("every monday").unwrap(), "0 0 * * 1");
|
assert_eq!(parse_natural_schedule("every monday").unwrap(), "0 0 * * 1");
|
||||||
assert_eq!(parse_natural_schedule("every friday").unwrap(), "0 0 * * 5");
|
assert_eq!(parse_natural_schedule("every friday").unwrap(), "0 0 * * 5");
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_day_with_time() {
|
fn test_day_with_time() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_natural_schedule("every monday at 9am").unwrap(),
|
parse_natural_schedule("every monday at 9am").unwrap(),
|
||||||
|
|
@ -114,7 +114,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_weekdays() {
|
fn test_weekdays() {
|
||||||
assert_eq!(parse_natural_schedule("weekdays").unwrap(), "0 0 * * 1-5");
|
assert_eq!(parse_natural_schedule("weekdays").unwrap(), "0 0 * * 1-5");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
@ -129,7 +129,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_weekends() {
|
fn test_weekends() {
|
||||||
assert_eq!(parse_natural_schedule("weekends").unwrap(), "0 0 * * 0,6");
|
assert_eq!(parse_natural_schedule("weekends").unwrap(), "0 0 * * 0,6");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
@ -140,7 +140,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_combined() {
|
fn test_combined() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_natural_schedule("every day at 9am").unwrap(),
|
parse_natural_schedule("every day at 9am").unwrap(),
|
||||||
|
|
@ -154,7 +154,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_hour_range() {
|
fn test_hour_range() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_natural_schedule("every hour from 9 to 17").unwrap(),
|
parse_natural_schedule("every hour from 9 to 17").unwrap(),
|
||||||
|
|
@ -164,7 +164,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_business_hours() {
|
fn test_business_hours() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_natural_schedule("business hours").unwrap(),
|
parse_natural_schedule("business hours").unwrap(),
|
||||||
|
|
@ -182,7 +182,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_raw_cron_passthrough() {
|
fn test_raw_cron_passthrough() {
|
||||||
assert_eq!(parse_natural_schedule("0 * * * *").unwrap(), "0 * * * *");
|
assert_eq!(parse_natural_schedule("0 * * * *").unwrap(), "0 * * * *");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
@ -197,8 +197,8 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_invalid_input() {
|
fn test_invalid_input() {
|
||||||
assert!(parse_natural_schedule("potato salad").is_err());
|
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());
|
||||||
}
|
}
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_normalize_phone_us_10_digit() {
|
fn test_normalize_phone_us_10_digit() {
|
||||||
assert_eq!(normalize_phone_number("5551234567"), "+15551234567");
|
assert_eq!(normalize_phone_number("5551234567"), "+15551234567");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_normalize_phone_us_11_digit() {
|
fn test_normalize_phone_us_11_digit() {
|
||||||
assert_eq!(normalize_phone_number("15551234567"), "+15551234567");
|
assert_eq!(normalize_phone_number("15551234567"), "+15551234567");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_normalize_phone_with_plus() {
|
fn test_normalize_phone_with_plus() {
|
||||||
assert_eq!(normalize_phone_number("+15551234567"), "+15551234567");
|
assert_eq!(normalize_phone_number("+15551234567"), "+15551234567");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_normalize_phone_with_formatting() {
|
fn test_normalize_phone_with_formatting() {
|
||||||
assert_eq!(normalize_phone_number("+1 (555) 123-4567"), "+15551234567");
|
assert_eq!(normalize_phone_number("+1 (555) 123-4567"), "+15551234567");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_normalize_phone_international() {
|
fn test_normalize_phone_international() {
|
||||||
assert_eq!(normalize_phone_number("+44 7911 123456"), "+447911123456");
|
assert_eq!(normalize_phone_number("+44 7911 123456"), "+447911123456");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sms_provider_from_str() {
|
fn test_sms_provider_from_str() {
|
||||||
assert_eq!(SmsProvider::from("twilio"), SmsProvider::Twilio);
|
assert_eq!(SmsProvider::from("twilio"), SmsProvider::Twilio);
|
||||||
assert_eq!(SmsProvider::from("aws_sns"), SmsProvider::AwsSns);
|
assert_eq!(SmsProvider::from("aws_sns"), SmsProvider::AwsSns);
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_engagement_to_dynamic() {
|
fn test_engagement_to_dynamic() {
|
||||||
let engagement = PostEngagement {
|
let engagement = PostEngagement {
|
||||||
likes: 100,
|
likes: 100,
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -9,9 +9,9 @@
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_module_structure() {
|
fn test_module_structure() {
|
||||||
// This test verifies the module compiles correctly
|
|
||||||
// Actual function tests are in the social/ module files
|
|
||||||
assert!(true);
|
assert!(true);
|
||||||
}
|
}
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_schedule_time() {
|
fn test_parse_schedule_time() {
|
||||||
let result = parse_schedule_time("2025-02-01 10:00");
|
let result = parse_schedule_time("2025-02-01 10:00");
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
|
|
||||||
|
|
@ -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};
|
use botserver::basic::keywords::string_functions::{instr_impl, is_numeric_impl};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_instr_basic() {
|
fn test_instr_basic() {
|
||||||
assert_eq!(instr_impl(1, "Hello, World!", "World"), 8);
|
assert_eq!(instr_impl(1, "Hello, World!", "World"), 8);
|
||||||
assert_eq!(instr_impl(1, "Hello, World!", "o"), 5);
|
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]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_instr_with_start() {
|
fn test_instr_with_start() {
|
||||||
assert_eq!(instr_impl(1, "one two one", "one"), 1);
|
assert_eq!(instr_impl(1, "one two one", "one"), 1);
|
||||||
assert_eq!(instr_impl(2, "one two one", "one"), 9);
|
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]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_instr_edge_cases() {
|
fn test_instr_edge_cases() {
|
||||||
assert_eq!(instr_impl(1, "", "test"), 0);
|
assert_eq!(instr_impl(1, "", "test"), 0);
|
||||||
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]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_is_numeric_integers() {
|
fn test_is_numeric_integers() {
|
||||||
assert!(is_numeric_impl("42"));
|
assert!(is_numeric_impl("42"));
|
||||||
assert!(is_numeric_impl("-17"));
|
assert!(is_numeric_impl("-17"));
|
||||||
|
|
@ -42,7 +42,7 @@ use botserver::basic::keywords::string_functions::{instr_impl, is_numeric_impl};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_is_numeric_decimals() {
|
fn test_is_numeric_decimals() {
|
||||||
assert!(is_numeric_impl("3.14"));
|
assert!(is_numeric_impl("3.14"));
|
||||||
assert!(is_numeric_impl("-0.5"));
|
assert!(is_numeric_impl("-0.5"));
|
||||||
|
|
@ -52,7 +52,7 @@ use botserver::basic::keywords::string_functions::{instr_impl, is_numeric_impl};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_is_numeric_scientific() {
|
fn test_is_numeric_scientific() {
|
||||||
assert!(is_numeric_impl("1e10"));
|
assert!(is_numeric_impl("1e10"));
|
||||||
assert!(is_numeric_impl("2.5E-3"));
|
assert!(is_numeric_impl("2.5E-3"));
|
||||||
|
|
@ -61,7 +61,7 @@ use botserver::basic::keywords::string_functions::{instr_impl, is_numeric_impl};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_is_numeric_invalid() {
|
fn test_is_numeric_invalid() {
|
||||||
assert!(!is_numeric_impl(""));
|
assert!(!is_numeric_impl(""));
|
||||||
assert!(!is_numeric_impl("abc"));
|
assert!(!is_numeric_impl("abc"));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_switch_match_strings() {
|
fn test_switch_match_strings() {
|
||||||
let a = Dynamic::from("hello");
|
let a = Dynamic::from("hello");
|
||||||
let b = Dynamic::from("hello");
|
let b = Dynamic::from("hello");
|
||||||
|
|
@ -23,7 +23,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_switch_match_integers() {
|
fn test_switch_match_integers() {
|
||||||
let a = Dynamic::from(42_i64);
|
let a = Dynamic::from(42_i64);
|
||||||
let b = Dynamic::from(42_i64);
|
let b = Dynamic::from(42_i64);
|
||||||
|
|
@ -35,7 +35,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_switch_match_floats() {
|
fn test_switch_match_floats() {
|
||||||
let a = Dynamic::from(3.14_f64);
|
let a = Dynamic::from(3.14_f64);
|
||||||
let b = Dynamic::from(3.14_f64);
|
let b = Dynamic::from(3.14_f64);
|
||||||
|
|
@ -47,7 +47,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_switch_match_mixed_numeric() {
|
fn test_switch_match_mixed_numeric() {
|
||||||
let int_val = Dynamic::from(42_i64);
|
let int_val = Dynamic::from(42_i64);
|
||||||
let float_val = Dynamic::from(42.0_f64);
|
let float_val = Dynamic::from(42.0_f64);
|
||||||
|
|
@ -57,7 +57,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_preprocess_simple_switch() {
|
fn test_preprocess_simple_switch() {
|
||||||
let input = r#"
|
let input = r#"
|
||||||
SWITCH role
|
SWITCH role
|
||||||
|
|
@ -77,7 +77,7 @@ END SWITCH
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_preprocess_multiple_values() {
|
fn test_preprocess_multiple_values() {
|
||||||
let input = r#"
|
let input = r#"
|
||||||
SWITCH day
|
SWITCH day
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_table_definition() {
|
fn test_parse_table_definition() {
|
||||||
let source = r#"
|
let source = r#"
|
||||||
TABLE Contacts ON maria
|
TABLE Contacts ON maria
|
||||||
|
|
@ -38,7 +38,7 @@ END TABLE
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_field_with_precision() {
|
fn test_parse_field_with_precision() {
|
||||||
let field = parse_field_definition("Preco double(10,2)", 0).unwrap();
|
let field = parse_field_definition("Preco double(10,2)", 0).unwrap();
|
||||||
assert_eq!(field.name, "Preco");
|
assert_eq!(field.name, "Preco");
|
||||||
|
|
@ -49,7 +49,7 @@ END TABLE
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_generate_create_table_sql() {
|
fn test_generate_create_table_sql() {
|
||||||
let table = TableDefinition {
|
let table = TableDefinition {
|
||||||
name: "TestTable".to_string(),
|
name: "TestTable".to_string(),
|
||||||
|
|
@ -89,7 +89,7 @@ END TABLE
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_map_types() {
|
fn test_map_types() {
|
||||||
let field = FieldDefinition {
|
let field = FieldDefinition {
|
||||||
name: "test".to_string(),
|
name: "test".to_string(),
|
||||||
|
|
@ -121,7 +121,7 @@ END TABLE
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_sanitize_identifier() {
|
fn test_sanitize_identifier() {
|
||||||
assert_eq!(sanitize_identifier("valid_name"), "valid_name");
|
assert_eq!(sanitize_identifier("valid_name"), "valid_name");
|
||||||
assert_eq!(sanitize_identifier("DROP TABLE; --"), "DROPTABLE");
|
assert_eq!(sanitize_identifier("DROP TABLE; --"), "DROPTABLE");
|
||||||
|
|
@ -130,7 +130,7 @@ END TABLE
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_build_connection_string() {
|
fn test_build_connection_string() {
|
||||||
let conn = ExternalConnection {
|
let conn = ExternalConnection {
|
||||||
name: "test".to_string(),
|
name: "test".to_string(),
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_priority_to_int() {
|
fn test_priority_to_int() {
|
||||||
assert_eq!(priority_to_int(Some("urgent")), 3);
|
assert_eq!(priority_to_int(Some("urgent")), 3);
|
||||||
assert_eq!(priority_to_int(Some("high")), 2);
|
assert_eq!(priority_to_int(Some("high")), 2);
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_find_attendant_by_name() {
|
fn test_find_attendant_by_name() {
|
||||||
let attendants = vec![
|
let attendants = vec![
|
||||||
Attendant {
|
Attendant {
|
||||||
|
|
@ -42,22 +42,22 @@
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// Find by exact name
|
|
||||||
let found = find_attendant(&attendants, Some("John Smith"), None);
|
let found = find_attendant(&attendants, Some("John Smith"), None);
|
||||||
assert!(found.is_some());
|
assert!(found.is_some());
|
||||||
assert_eq!(found.unwrap().id, "att-001");
|
assert_eq!(found.unwrap().id, "att-001");
|
||||||
|
|
||||||
// Find by partial name
|
|
||||||
let found = find_attendant(&attendants, Some("john"), None);
|
let found = find_attendant(&attendants, Some("john"), None);
|
||||||
assert!(found.is_some());
|
assert!(found.is_some());
|
||||||
assert_eq!(found.unwrap().id, "att-001");
|
assert_eq!(found.unwrap().id, "att-001");
|
||||||
|
|
||||||
// Find by alias
|
|
||||||
let found = find_attendant(&attendants, Some("johnny"), None);
|
let found = find_attendant(&attendants, Some("johnny"), None);
|
||||||
assert!(found.is_some());
|
assert!(found.is_some());
|
||||||
assert_eq!(found.unwrap().id, "att-001");
|
assert_eq!(found.unwrap().id, "att-001");
|
||||||
|
|
||||||
// Find by department
|
|
||||||
let found = find_attendant(&attendants, None, Some("customer-service"));
|
let found = find_attendant(&attendants, None, Some("customer-service"));
|
||||||
assert!(found.is_some());
|
assert!(found.is_some());
|
||||||
assert_eq!(found.unwrap().id, "att-002");
|
assert_eq!(found.unwrap().id, "att-002");
|
||||||
|
|
@ -65,7 +65,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_transfer_result_to_dynamic() {
|
fn test_transfer_result_to_dynamic() {
|
||||||
let result = TransferResult {
|
let result = TransferResult {
|
||||||
success: true,
|
success: true,
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_account_path() {
|
fn test_parse_account_path() {
|
||||||
let result = parse_account_path("account://user@gmail.com/Documents/file.pdf");
|
let result = parse_account_path("account://user@gmail.com/Documents/file.pdf");
|
||||||
assert!(result.is_some());
|
assert!(result.is_some());
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_parse_account_path_invalid() {
|
fn test_parse_account_path_invalid() {
|
||||||
assert!(parse_account_path("local/file.pdf").is_none());
|
assert!(parse_account_path("local/file.pdf").is_none());
|
||||||
assert!(parse_account_path("/absolute/path").is_none());
|
assert!(parse_account_path("/absolute/path").is_none());
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_is_account_path() {
|
fn test_is_account_path() {
|
||||||
assert!(is_account_path("account://user@gmail.com/file.pdf"));
|
assert!(is_account_path("account://user@gmail.com/file.pdf"));
|
||||||
assert!(!is_account_path("local/file.pdf"));
|
assert!(!is_account_path("local/file.pdf"));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -8,15 +8,15 @@
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
use rhai::Engine;
|
use rhai::Engine;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_use_kb_syntax() {
|
fn test_use_kb_syntax() {
|
||||||
let mut engine = Engine::new();
|
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
|
assert!(engine
|
||||||
.register_custom_syntax(&["USE_KB", "$expr$"], true, |_, _| Ok(Dynamic::UNIT))
|
.register_custom_syntax(&["USE_KB", "$expr$"], true, |_, _| Ok(Dynamic::UNIT))
|
||||||
.is_ok());
|
.is_ok());
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -8,11 +8,11 @@
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
use rhai::Engine;
|
use rhai::Engine;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_url_sanitization() {
|
fn test_url_sanitization() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
sanitize_url_for_collection("https://docs.example.com/path"),
|
sanitize_url_for_collection("https://docs.example.com/path"),
|
||||||
|
|
@ -26,16 +26,16 @@ use rhai::Engine;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_use_website_syntax() {
|
fn test_use_website_syntax() {
|
||||||
let mut engine = Engine::new();
|
let mut engine = Engine::new();
|
||||||
|
|
||||||
// Test USE_WEBSITE with argument
|
|
||||||
assert!(engine
|
assert!(engine
|
||||||
.register_custom_syntax(&["USE_WEBSITE", "$expr$"], true, |_, _| Ok(Dynamic::UNIT))
|
.register_custom_syntax(&["USE_WEBSITE", "$expr$"], true, |_, _| Ok(Dynamic::UNIT))
|
||||||
.is_ok());
|
.is_ok());
|
||||||
|
|
||||||
// Test CLEAR_WEBSITES without argument
|
|
||||||
assert!(engine
|
assert!(engine
|
||||||
.register_custom_syntax(&["CLEAR_WEBSITES"], true, |_, _| Ok(Dynamic::UNIT))
|
.register_custom_syntax(&["CLEAR_WEBSITES"], true, |_, _| Ok(Dynamic::UNIT))
|
||||||
.is_ok());
|
.is_ok());
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_fact_key_generation() {
|
fn test_fact_key_generation() {
|
||||||
let fact_key = format!("fact_{}", Uuid::new_v4());
|
let fact_key = format!("fact_{}", Uuid::new_v4());
|
||||||
assert!(fact_key.starts_with("fact_"));
|
assert!(fact_key.starts_with("fact_"));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,12 +7,12 @@
|
||||||
|
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
use rhai::{Array, Map};
|
use rhai::{Array, Map};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_empty_string() {
|
fn test_empty_string() {
|
||||||
let value = Dynamic::from("");
|
let value = Dynamic::from("");
|
||||||
assert!(check_empty(&value));
|
assert!(check_empty(&value));
|
||||||
|
|
@ -20,7 +20,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_non_empty_string() {
|
fn test_non_empty_string() {
|
||||||
let value = Dynamic::from("hello");
|
let value = Dynamic::from("hello");
|
||||||
assert!(!check_empty(&value));
|
assert!(!check_empty(&value));
|
||||||
|
|
@ -28,7 +28,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_empty_array() {
|
fn test_empty_array() {
|
||||||
let value = Dynamic::from(Array::new());
|
let value = Dynamic::from(Array::new());
|
||||||
assert!(check_empty(&value));
|
assert!(check_empty(&value));
|
||||||
|
|
@ -36,7 +36,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_non_empty_array() {
|
fn test_non_empty_array() {
|
||||||
let mut arr = Array::new();
|
let mut arr = Array::new();
|
||||||
arr.push(Dynamic::from(1));
|
arr.push(Dynamic::from(1));
|
||||||
|
|
@ -46,7 +46,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_empty_map() {
|
fn test_empty_map() {
|
||||||
let value = Dynamic::from(Map::new());
|
let value = Dynamic::from(Map::new());
|
||||||
assert!(check_empty(&value));
|
assert!(check_empty(&value));
|
||||||
|
|
@ -54,7 +54,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_unit() {
|
fn test_unit() {
|
||||||
let value = Dynamic::UNIT;
|
let value = Dynamic::UNIT;
|
||||||
assert!(check_empty(&value));
|
assert!(check_empty(&value));
|
||||||
|
|
@ -62,7 +62,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_number_not_empty() {
|
fn test_number_not_empty() {
|
||||||
let value = Dynamic::from(0);
|
let value = Dynamic::from(0);
|
||||||
assert!(!check_empty(&value));
|
assert!(!check_empty(&value));
|
||||||
|
|
@ -70,7 +70,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_bool_not_empty() {
|
fn test_bool_not_empty() {
|
||||||
let value = Dynamic::from(false);
|
let value = Dynamic::from(false);
|
||||||
assert!(!check_empty(&value));
|
assert!(!check_empty(&value));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -12,7 +12,7 @@ use rhai::Dynamic;
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_isnull_unit() {
|
fn test_isnull_unit() {
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
let value = Dynamic::UNIT;
|
let value = Dynamic::UNIT;
|
||||||
|
|
@ -21,7 +21,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_isnull_not_unit() {
|
fn test_isnull_not_unit() {
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
let value = Dynamic::from("test");
|
let value = Dynamic::from("test");
|
||||||
|
|
@ -30,7 +30,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_isnull_number() {
|
fn test_isnull_number() {
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
let value = Dynamic::from(42);
|
let value = Dynamic::from(42);
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_nvl_logic() {
|
fn test_nvl_logic() {
|
||||||
let value = "";
|
let value = "";
|
||||||
let default = "default";
|
let default = "default";
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_nvl_with_value() {
|
fn test_nvl_with_value() {
|
||||||
let value = "actual";
|
let value = "actual";
|
||||||
let default = "default";
|
let default = "default";
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_iif_true() {
|
fn test_iif_true() {
|
||||||
let condition = true;
|
let condition = true;
|
||||||
let result = if condition { "yes" } else { "no" };
|
let result = if condition { "yes" } else { "no" };
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_iif_false() {
|
fn test_iif_false() {
|
||||||
let condition = false;
|
let condition = false;
|
||||||
let result = if condition { "yes" } else { "no" };
|
let result = if condition { "yes" } else { "no" };
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_choose() {
|
fn test_choose() {
|
||||||
let index = 2;
|
let index = 2;
|
||||||
let values = vec!["first", "second", "third"];
|
let values = vec!["first", "second", "third"];
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn test_val_parsing() {
|
fn test_val_parsing() {
|
||||||
assert_eq!("123.45".trim().parse::<f64>().unwrap_or(0.0), 123.45);
|
assert_eq!("123.45".trim().parse::<f64>().unwrap_or(0.0), 123.45);
|
||||||
assert_eq!(" 456 ".trim().parse::<f64>().unwrap_or(0.0), 456.0);
|
assert_eq!(" 456 ".trim().parse::<f64>().unwrap_or(0.0), 456.0);
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_cint_rounding() {
|
fn test_cint_rounding() {
|
||||||
assert_eq!(2.4_f64.round() as i64, 2);
|
assert_eq!(2.4_f64.round() as i64, 2);
|
||||||
assert_eq!(2.5_f64.round() as i64, 3);
|
assert_eq!(2.5_f64.round() as i64, 3);
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use rhai::Dynamic;
|
use rhai::Dynamic;
|
||||||
|
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_get_type_name() {
|
fn test_get_type_name() {
|
||||||
assert_eq!(get_type_name(&Dynamic::UNIT), "null");
|
assert_eq!(get_type_name(&Dynamic::UNIT), "null");
|
||||||
assert_eq!(get_type_name(&Dynamic::from(true)), "boolean");
|
assert_eq!(get_type_name(&Dynamic::from(true)), "boolean");
|
||||||
|
|
@ -22,7 +22,7 @@ use rhai::Dynamic;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_is_numeric() {
|
fn test_is_numeric() {
|
||||||
assert!(is_numeric(&Dynamic::from(42_i64)));
|
assert!(is_numeric(&Dynamic::from(42_i64)));
|
||||||
assert!(is_numeric(&Dynamic::from(3.14_f64)));
|
assert!(is_numeric(&Dynamic::from(3.14_f64)));
|
||||||
|
|
|
||||||
|
|
@ -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_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Original: use super::*; - tests used internal functions from botserver
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_degrees_to_compass() {
|
fn test_degrees_to_compass() {
|
||||||
assert_eq!(degrees_to_compass(0.0), "N");
|
assert_eq!(degrees_to_compass(0.0), "N");
|
||||||
assert_eq!(degrees_to_compass(45.0), "NE");
|
assert_eq!(degrees_to_compass(45.0), "NE");
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
|
|
||||||
fn test_format_weather_response() {
|
fn test_format_weather_response() {
|
||||||
let weather = WeatherData {
|
let weather = WeatherData {
|
||||||
location: "London".to_string(),
|
location: "London".to_string(),
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue