Repository navigation
Duplicated formula validation type removal - #419
Conversation
bc6e08d to
d51201f
Compare
|
@c-git On the testing question: I'd rather not add One thing I noticed while trying it: checking the value after reading does not catch a wrong tag. Could you add something like this to #[cfg(test)]
mod tests {
use super::*;
use crate::structs::{
Address,
office::excel::Formula,
};
fn formula(address: &str) -> Formula {
let mut a = Address::default();
a.set_address(address);
let mut f = Formula::default();
f.set_value(a);
f
}
#[test]
fn write_uses_correct_formula_tags() {
let mut dv = DataValidation::default();
let mut f1 = DataValidationFormula1::default();
f1.set_value(formula("Sheet1!$A$1"));
let mut f2 = DataValidationFormula2::default();
f2.set_value(formula("Sheet1!$B$1"));
dv.set_formula1(f1).set_formula2(f2);
let mut writer = Writer::new(Cursor::new(Vec::new()));
dv.write_to(&mut writer);
let xml = String::from_utf8(writer.into_inner().into_inner()).unwrap();
assert!(
xml.contains(
"<x14:formula1><xm:f>Sheet1!$A$1</xm:f></x14:formula1>\
<x14:formula2><xm:f>Sheet1!$B$1</xm:f></x14:formula2>"
),
"{xml}"
);
}
}If we want snapshot testing for the XML writers more broadly, I'm open to discussing |
|
I agree, unless it is going to be used broadly it wouldn't make sense just for this one test. (It's just my go to anytime I'm going to assert a specific value that I might want to update in the future). Will test the code you provided thank you so much for your help. PS. Always feel free to edit any of my PRs as you see fit. I always enable maintainer edits. |
|
Added. Thank you very much I'm much more comfortable with the test in place. |
|
@c-git |
Not ready for review. Will turn it to ready after #418 lands an I rebase this PR to clean up the diff.Landed.Created this PR to demonstrate what I meant. It's not complete for two reasons.
I branched from another PR that renames the files in this PR. So I'd need to wait for that one to land before I can land this one as I'd need to rebase it to clean up this PR.Closes: #416
I guess the code won't be worse that it was before without the tests but it feels weird to add code with no tests. I'm not quite sure how to test it though. Maybe we could look for the value in the existing test? I don't know enough to know if that makes sense.
My naive idea is to use insta to save a snapshot of the value read so if the tag were to be wrong it wouldn't get the value. I would use insta because it would make it easier if the expected value changes later.