Added additional response error.
All checks were successful
MoreThanText/morethantext/pipeline/head This commit looks good

This commit is contained in:
Jeff Baskin 2025-02-14 18:00:37 -05:00
parent 54fbfa7f9c
commit 7d2f79d736

View File

@ -156,6 +156,9 @@ impl Response {
self.data.insert(key.to_string(), store);
}
} else {
if rec.len() != self.data.len() {
return Err("incorrect number of columns".to_string());
}
for (key, value) in rec.iter() {
match self.data.get_mut(key) {
Some(data) => data.push(value.clone()),
@ -244,6 +247,21 @@ mod responses {
Err(_) => {}
}
}
#[test]
fn missing_field_error() {
let mut res = Response::new();
let mut rec1 = Record::new();
let mut rec2 = Record::new();
rec1.add("one", "one");
rec2.add("one", "one");
rec2.add("two", "two");
res.add(rec2).unwrap();
match res.add(rec1) {
Ok(_) => unreachable!("Should not accept additional value"),
Err(_) => {}
}
}
}
/// Support functions for Messages.