moved trigger tests to client.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
This commit is contained in:
@@ -13,6 +13,7 @@ fn can_a_trigger_cause_an_update() {
|
|||||||
let data1_expected = 1;
|
let data1_expected = 1;
|
||||||
let mut test_env = TestMoreThanText::new();
|
let mut test_env = TestMoreThanText::new();
|
||||||
let mut mtt = test_env.get_morethantext();
|
let mut mtt = test_env.get_morethantext();
|
||||||
|
let client = mtt.client();
|
||||||
let test_doc = TestDocument::new(vec![FieldType::Integer, FieldType::Integer]);
|
let test_doc = TestDocument::new(vec![FieldType::Integer, FieldType::Integer]);
|
||||||
let mut calc = Calculation::new(Operand::Add);
|
let mut calc = Calculation::new(Operand::Add);
|
||||||
calc.add_value(CalcValue::Existing(FieldType::Integer))
|
calc.add_value(CalcValue::Existing(FieldType::Integer))
|
||||||
@@ -28,7 +29,7 @@ fn can_a_trigger_cause_an_update() {
|
|||||||
let function = DocFuncType::ExistingQuery(update.into());
|
let function = DocFuncType::ExistingQuery(update.into());
|
||||||
let mut docdef = test_doc.get_docdef();
|
let mut docdef = test_doc.get_docdef();
|
||||||
docdef.add_route(path, function);
|
docdef.add_route(path, function);
|
||||||
mtt.create_document(docdef);
|
client.create_document(docdef);
|
||||||
test_doc.populate(mtt.clone(), vec![data0.clone(), data1.clone()]);
|
test_doc.populate(mtt.clone(), vec![data0.clone(), data1.clone()]);
|
||||||
let path = Path::new(
|
let path = Path::new(
|
||||||
Include::All,
|
Include::All,
|
||||||
@@ -36,7 +37,7 @@ fn can_a_trigger_cause_an_update() {
|
|||||||
Include::Just(Action::OnUpdate),
|
Include::Just(Action::OnUpdate),
|
||||||
);
|
);
|
||||||
test_env.register_channel(vec![path]);
|
test_env.register_channel(vec![path]);
|
||||||
let first_qry = mtt.records(Query::new(test_doc.get_doc_name())).unwrap();
|
let first_qry = client.records(Query::new(test_doc.get_doc_name())).unwrap();
|
||||||
assert_eq!(first_qry.len(), 1);
|
assert_eq!(first_qry.len(), 1);
|
||||||
let first_rec = first_qry.iter().last().unwrap();
|
let first_rec = first_qry.iter().last().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -72,6 +73,7 @@ fn can_trigger_update_specific_record() {
|
|||||||
}
|
}
|
||||||
let mut test_env = TestMoreThanText::new();
|
let mut test_env = TestMoreThanText::new();
|
||||||
let mut mtt = test_env.get_morethantext();
|
let mut mtt = test_env.get_morethantext();
|
||||||
|
let client = mtt.client();
|
||||||
let test_doc = TestDocument::new(vec![FieldType::Integer, FieldType::Integer]);
|
let test_doc = TestDocument::new(vec![FieldType::Integer, FieldType::Integer]);
|
||||||
let mut calc = Calculation::new(Operand::Add);
|
let mut calc = Calculation::new(Operand::Add);
|
||||||
calc.add_value(CalcValue::Existing(FieldType::Integer))
|
calc.add_value(CalcValue::Existing(FieldType::Integer))
|
||||||
@@ -87,7 +89,7 @@ fn can_trigger_update_specific_record() {
|
|||||||
let function = DocFuncType::ExistingQuery(update.into());
|
let function = DocFuncType::ExistingQuery(update.into());
|
||||||
let mut docdef = test_doc.get_docdef();
|
let mut docdef = test_doc.get_docdef();
|
||||||
docdef.add_route(path, function);
|
docdef.add_route(path, function);
|
||||||
mtt.create_document(docdef);
|
client.create_document(docdef);
|
||||||
test_doc.populate_multiple(mtt.clone(), input);
|
test_doc.populate_multiple(mtt.clone(), input);
|
||||||
let mut qry_calc = Calculation::new(Operand::Equal);
|
let mut qry_calc = Calculation::new(Operand::Equal);
|
||||||
qry_calc
|
qry_calc
|
||||||
@@ -102,7 +104,7 @@ fn can_trigger_update_specific_record() {
|
|||||||
Include::Just(Action::OnUpdate),
|
Include::Just(Action::OnUpdate),
|
||||||
);
|
);
|
||||||
test_env.register_channel(vec![path]);
|
test_env.register_channel(vec![path]);
|
||||||
let first_result = mtt.records(qry).unwrap();
|
let first_result = client.records(qry).unwrap();
|
||||||
assert_eq!(first_result.len(), 1);
|
assert_eq!(first_result.len(), 1);
|
||||||
let first_rec = first_result.iter().last().unwrap();
|
let first_rec = first_result.iter().last().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -136,6 +138,7 @@ fn can_a_trigger_from_another_document_be_used() {
|
|||||||
}
|
}
|
||||||
let mut test_env = TestMoreThanText::new();
|
let mut test_env = TestMoreThanText::new();
|
||||||
let mut mtt = test_env.get_morethantext();
|
let mut mtt = test_env.get_morethantext();
|
||||||
|
let client = mtt.client();
|
||||||
let test_doc = TestDocument::new(vec![FieldType::Integer]);
|
let test_doc = TestDocument::new(vec![FieldType::Integer]);
|
||||||
let mut calc = Calculation::new(Operand::Equal);
|
let mut calc = Calculation::new(Operand::Equal);
|
||||||
calc.add_value(CalcValue::Existing(FieldType::Integer))
|
calc.add_value(CalcValue::Existing(FieldType::Integer))
|
||||||
@@ -151,7 +154,7 @@ fn can_a_trigger_from_another_document_be_used() {
|
|||||||
let function = DocFuncType::Trigger(delete.into());
|
let function = DocFuncType::Trigger(delete.into());
|
||||||
let mut docdef = test_doc.get_docdef();
|
let mut docdef = test_doc.get_docdef();
|
||||||
docdef.add_route(path, function);
|
docdef.add_route(path, function);
|
||||||
mtt.create_document(docdef);
|
client.create_document(docdef);
|
||||||
test_doc.populate_multiple(mtt.clone(), input);
|
test_doc.populate_multiple(mtt.clone(), input);
|
||||||
let path = Path::new(
|
let path = Path::new(
|
||||||
Include::All,
|
Include::All,
|
||||||
@@ -191,10 +194,11 @@ fn can_triggers_work_with_multiple_languages() {
|
|||||||
docdef.add_route(path, function);
|
docdef.add_route(path, function);
|
||||||
let mut test_env = TestMoreThanText::new();
|
let mut test_env = TestMoreThanText::new();
|
||||||
let mut mtt = test_env.get_morethantext();
|
let mut mtt = test_env.get_morethantext();
|
||||||
mtt.create_document(docdef).unwrap();
|
let client = mtt.client();
|
||||||
|
client.create_document(docdef).unwrap();
|
||||||
let mut data = Addition::new(doc_names[0].clone());
|
let mut data = Addition::new(doc_names[0].clone());
|
||||||
data.add_field(field_names[0].clone(), initial_data.clone());
|
data.add_field(field_names[0].clone(), initial_data.clone());
|
||||||
mtt.records(data).unwrap();
|
client.records(data).unwrap();
|
||||||
let mut qry_calc = Calculation::new(Operand::LessThan);
|
let mut qry_calc = Calculation::new(Operand::LessThan);
|
||||||
qry_calc.add_value(0).unwrap();
|
qry_calc.add_value(0).unwrap();
|
||||||
qry_calc
|
qry_calc
|
||||||
@@ -210,7 +214,7 @@ fn can_triggers_work_with_multiple_languages() {
|
|||||||
let holder: i128 = i.clone().try_into().unwrap();
|
let holder: i128 = i.clone().try_into().unwrap();
|
||||||
let mut query = Query::new(doc_names[i].clone());
|
let mut query = Query::new(doc_names[i].clone());
|
||||||
query.add(field_names[i].clone(), qry_calc.clone());
|
query.add(field_names[i].clone(), qry_calc.clone());
|
||||||
let qry_result = mtt.records(query.clone()).unwrap();
|
let qry_result = client.records(query.clone()).unwrap();
|
||||||
assert_eq!(qry_result.len(), 1, "got {:?} from {:?}", qry_result, query);
|
assert_eq!(qry_result.len(), 1, "got {:?} from {:?}", qry_result, query);
|
||||||
let qry_rec = qry_result.iter().last().unwrap();
|
let qry_rec = qry_result.iter().last().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
Reference in New Issue
Block a user