[pve-devel] [PATCH installer v2 11/17] auto-installer: tests: replace manual panic!() with assert_eq!()

Christoph Heiss c.heiss at proxmox.com
Tue Jul 23 12:46:24 CEST 2024


On Tue, Jul 23, 2024 at 12:39:20PM GMT, Aaron Lauterer wrote:
> Do we still see which test case actually failed? IIRC I used the panic so I
> can print the needed info, mainly the name of the current test scenario so
> it is easier to find out which failed.

Yes, since it printed earlier in the code, at the start of the
`if extension == "toml" { .. }` block.

>
> On  2024-07-18  15:48, Christoph Heiss wrote:
> > Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
> > ---
> > Changes v1 -> v2:
> >    * new patch, suggested by Stefan
> > ---
> >   proxmox-auto-installer/tests/parse-answer.rs | 8 ++------
> >   1 file changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/proxmox-auto-installer/tests/parse-answer.rs b/proxmox-auto-installer/tests/parse-answer.rs
> > index 450915a..1fc515e 100644
> > --- a/proxmox-auto-installer/tests/parse-answer.rs
> > +++ b/proxmox-auto-installer/tests/parse-answer.rs
> > @@ -75,12 +75,8 @@ fn test_parse_answers() {
> >               path.push(format!("{name}.json"));
> >               let compare_raw = std::fs::read_to_string(&path).unwrap();
> >               let compare: Value = serde_json::from_str(&compare_raw).unwrap();
> > -            if config != compare {
> > -                panic!(
> > -                    "Test {} failed:\nleft:  {:#?}\nright: {:#?}\n",
> > -                    name, config, compare
> > -                );
> > -            }
> > +
> > +            assert_eq!(config, compare);
> >           }
> >       }
> >   }
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>




More information about the pve-devel mailing list