use dbnexus::{ActiveModelTrait, Condition, EntityTrait};
use sea_orm::ActiveValue;
#[test]
fn test_condition_all() {
let condition = Condition::all();
assert!(!format!("{condition:?}").is_empty());
}
#[test]
fn test_condition_any() {
let condition = Condition::any();
assert!(!format!("{condition:?}").is_empty());
}
#[test]
fn test_condition_not() {
let condition = Condition::not(Condition::all());
assert!(!format!("{condition:?}").is_empty());
}
#[test]
fn test_condition_combination() {
let condition = Condition::all()
.add(Condition::any())
.add(Condition::not(Condition::all()));
let combined = Condition::all().add(Condition::all()).add(Condition::any());
assert!(!format!("{condition:?}").is_empty());
assert!(!format!("{combined:?}").is_empty());
}
#[test]
fn test_condition_nested_combination() {
let condition = Condition::all().add(Condition::any());
assert!(!format!("{condition:?}").is_empty());
}
#[test]
fn test_condition_not_nested() {
let condition = Condition::not(Condition::all()).add(Condition::any());
assert!(!format!("{condition:?}").is_empty());
}
#[test]
fn test_set_string() {
let set_value = ActiveValue::Set("test".to_string());
assert!(matches!(set_value, ActiveValue::Set(_)));
}
#[test]
fn test_set_number() {
let set_number = ActiveValue::Set(42);
assert!(matches!(set_number, ActiveValue::Set(42)));
}
#[test]
fn test_set_option() {
let set_option = ActiveValue::Set(Some(42));
assert!(matches!(set_option, ActiveValue::Set(Some(42))));
}
#[test]
fn test_set_none() {
let none_value: ActiveValue<Option<i32>> = ActiveValue::Set(None);
assert!(matches!(none_value, ActiveValue::Set(None)));
}
#[test]
fn test_active_value_not_set() {
let not_set: ActiveValue<String> = ActiveValue::NotSet;
assert!(matches!(not_set, ActiveValue::NotSet));
}
#[test]
fn test_active_value_unchanged() {
let unchanged: ActiveValue<String> = ActiveValue::Unchanged("original".to_string());
assert!(matches!(unchanged, ActiveValue::Unchanged(_)));
}
#[test]
fn test_type_exports() {
let _condition = Condition::all();
let _set_value = ActiveValue::Set("test");
let _string_type: ActiveValue<String> = ActiveValue::Set(String::new());
let _i32_type: ActiveValue<i32> = ActiveValue::Set(0);
let _option_type: ActiveValue<Option<String>> = ActiveValue::Set(None);
}
#[test]
fn test_condition_logical_operations() {
let condition1 = Condition::all();
let condition2 = Condition::any();
let and_result = condition1.clone().add(condition2.clone());
assert!(!format!("{and_result:?}").is_empty());
assert!(!format!("{condition1:?}").is_empty());
assert!(!format!("{condition2:?}").is_empty());
}
#[test]
fn test_set_various_types() {
let _s1: ActiveValue<String> = ActiveValue::Set("hello".to_string());
let _s2: ActiveValue<Option<String>> = ActiveValue::Set(Some("world".to_string()));
let _n1: ActiveValue<i32> = ActiveValue::Set(42);
let _n2: ActiveValue<i64> = ActiveValue::Set(1234567890i64);
let _n3: ActiveValue<f64> = ActiveValue::Set(2.5);
let _b1: ActiveValue<bool> = ActiveValue::Set(true);
let _b2: ActiveValue<bool> = ActiveValue::Set(false);
use chrono::{DateTime, Utc};
let _t1: ActiveValue<DateTime<Utc>> = ActiveValue::Set(Utc::now());
let _t2: ActiveValue<Option<DateTime<Utc>>> = ActiveValue::Set(Some(Utc::now()));
let condition = Condition::all();
assert!(!format!("{condition:?}").is_empty());
}
#[test]
fn test_active_model_trait_bound() {
fn _assert_active_model_trait<T: ActiveModelTrait>() {}
fn _assert_entity_trait<T: EntityTrait>() {}
}
#[test]
fn test_condition_format() {
let conditions: Vec<Condition> = vec![
Condition::all(),
Condition::any(),
Condition::not(Condition::all()),
Condition::all().add(Condition::any()),
];
for condition in conditions {
let debug = format!("{condition:?}");
assert!(!debug.is_empty(), "Debug format should not be empty");
}
}