Moved the rest of the trigger tests to lib.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
This commit is contained in:
@@ -3,7 +3,8 @@ mod support;
|
||||
use chrono::Utc;
|
||||
use morethantext::{
|
||||
action::{Addition, DocDef, Field, FieldType, Query},
|
||||
Calculation, ErrorID, IndexType, MTTError, MoreThanText, Name, Operand,
|
||||
Action, CalcValue, Calculation, ErrorID, Include, IndexType, MTTError, MoreThanText, Name,
|
||||
Operand, Path, TestMoreThanText,
|
||||
};
|
||||
use std::{collections::HashSet, time::Duration};
|
||||
use support::{random_name, TestDocument};
|
||||
@@ -186,3 +187,35 @@ fn are_unique_indexes_maintained_with_additions() {
|
||||
let result = mtt.records(add).unwrap_err();
|
||||
assert_eq!(result.to_string(), err.to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_addition_send_on_query_message() {
|
||||
let mut test_env = TestMoreThanText::new();
|
||||
let mut mtt = test_env.get_morethantext();
|
||||
let test_doc = TestDocument::new(vec![FieldType::Integer]);
|
||||
mtt.create_document(test_doc.get_docdef()).unwrap();
|
||||
test_env.register_channel(vec![Path::new(
|
||||
Include::All,
|
||||
Include::Just(test_doc.get_doc_name().into()),
|
||||
Include::Just(Action::OnAddition),
|
||||
)]);
|
||||
let mut add = Addition::new(test_doc.get_doc_name());
|
||||
add.add_field(test_doc.get_field_name(0), 2);
|
||||
let add_result = mtt.records(add).unwrap();
|
||||
let trigger_result = test_env.get_trigger_records(Action::OnAddition);
|
||||
assert_eq!(trigger_result.len(), add_result.len());
|
||||
assert_eq!(
|
||||
trigger_result
|
||||
.iter()
|
||||
.last()
|
||||
.unwrap()
|
||||
.get(test_doc.get_field_name(0))
|
||||
.unwrap(),
|
||||
add_result
|
||||
.iter()
|
||||
.last()
|
||||
.unwrap()
|
||||
.get(test_doc.get_field_name(0))
|
||||
.unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user