Got document file to respond to update.
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:
parent
6c8ee13d99
commit
841f935c8d
@ -1593,6 +1593,14 @@ impl Update {
|
||||
values: Document::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_query_mut(&mut self) -> &mut Query {
|
||||
&mut self.query
|
||||
}
|
||||
|
||||
fn get_values_mut(&mut self) -> &mut Document {
|
||||
&mut self.values
|
||||
}
|
||||
}
|
||||
|
||||
struct DocumentFile {
|
||||
@ -1634,6 +1642,11 @@ impl DocumentFile {
|
||||
Include::Some(name.clone()),
|
||||
Include::Some(Action::Show),
|
||||
),
|
||||
RouteRequest::new(
|
||||
Include::All,
|
||||
Include::Some(name.clone()),
|
||||
Include::Some(Action::Update),
|
||||
),
|
||||
]
|
||||
.to_vec();
|
||||
match queue.register(tx, name, routes) {
|
||||
@ -2244,9 +2257,51 @@ mod document_files {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_update_query_results_in_zero_changes() {
|
||||
let doc_name = "testing";
|
||||
let mut docdef = create_docdef([FieldType::Uuid].to_vec());
|
||||
fn empty_update_query_results_in_zero_changes() {
|
||||
let (mut docdef, doc_name) = create_docdef([FieldType::Uuid].to_vec());
|
||||
let (queue, rx) = test_doc(doc_name.as_str(), docdef, standard_routes());
|
||||
let mut update = Update::new();
|
||||
update
|
||||
.get_query_mut()
|
||||
.add_specifier("field0".to_string(), Operand::Equal, Uuid::new_v4());
|
||||
update
|
||||
.get_values_mut()
|
||||
.add_field("field0".to_string(), Uuid::nil());
|
||||
let msg = Message::new(doc_name, update);
|
||||
queue.send(msg).unwrap();
|
||||
let result = rx.recv_timeout(TIMEOUT).unwrap();
|
||||
let action = result.get_action();
|
||||
match action {
|
||||
MsgAction::Reply(docs) => assert_eq!(docs.len(), 0),
|
||||
_ => unreachable!("got {:?}: should have gotten a reply", action),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_responses_to_its_update_request() {
|
||||
let (mut docdef, doc_name) = create_docdef([FieldType::Uuid].to_vec());
|
||||
let (mut queue, rx) = test_doc(doc_name.as_str(), docdef, standard_routes());
|
||||
let alt_doc_name = "alternate";
|
||||
let (tx, _) = channel();
|
||||
queue
|
||||
.register(tx, alt_doc_name.to_string(), Vec::new())
|
||||
.unwrap();
|
||||
let mut update = Update::new();
|
||||
update
|
||||
.get_query_mut()
|
||||
.add_specifier("field0".to_string(), Operand::Equal, Uuid::new_v4());
|
||||
update
|
||||
.get_values_mut()
|
||||
.add_field("field0".to_string(), Uuid::nil());
|
||||
let msg = Message::new(alt_doc_name, update);
|
||||
queue.send(msg).unwrap();
|
||||
match rx.recv_timeout(TIMEOUT) {
|
||||
Ok(msg) => unreachable!("should not receive: {:?}", msg),
|
||||
Err(err) => match err {
|
||||
RecvTimeoutError::Timeout => {}
|
||||
_ => unreachable!("should have timed out"),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user