[libvirt] [PATCH rust 2/5] make lookup_by_id() test more robust

Sahid Orentino Ferdjaoui sahid.ferdjaoui at canonical.com
Fri Jul 5 10:41:34 UTC 2019


On Fri, Jul 05, 2019 at 09:49:02AM +0100, Daniel P. Berrangé wrote:
> On Thu, Jul 04, 2019 at 12:15:26PM +0200, Sahid Orentino Ferdjaoui wrote:
> > Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui at canonical.com>
> > ---
> >  tests/domain.rs | 19 +++++++++----------
> >  1 file changed, 9 insertions(+), 10 deletions(-)
> > 
> > diff --git a/tests/domain.rs b/tests/domain.rs
> > index 5a64a75..a70139e 100644
> > --- a/tests/domain.rs
> > +++ b/tests/domain.rs
> > @@ -89,26 +89,25 @@ fn test_get_vcpus_flags() {
> >  }
> >  
> >  #[test]
> > -fn test_lookup_domain_by_id() {
> > +fn test_lookup_domain_by_name() {
> >      let c = common::conn();
> > -    let v = c.list_domains().unwrap_or(vec![]);
> > -    assert!(0 < v.len(), "At least one domain should exist");
> > -    for domid in v {
> > -        match Domain::lookup_by_id(&c, domid) {
> > -            Ok(mut dom) => dom.free().unwrap_or(()),
> > -            Err(e) => panic!("failed with code {}, message: {}", e.code, e.message),
> > -        }
> > +    match Domain::lookup_by_name(&c, "test") {
> > +        Ok(mut r) => r.free().unwrap_or(()),
> > +        Err(e) => panic!("failed with code {}, message: {}", e.code, e.message),
> >      }
> >      common::close(c);
> >  }
> >  
> >  #[test]
> > -fn test_lookup_domain_by_name() {
> > +fn test_lookup_domain_by_id() {
> >      let c = common::conn();
> > -    match Domain::lookup_by_name(&c, "test") {
> > +    let d = common::build_test_domain(&c, "by_id", true);
> > +    let id = d.get_id().unwrap_or(0);
> > +    match Domain::lookup_by_id(&c, id) {
> >          Ok(mut r) => r.free().unwrap_or(()),
> >          Err(e) => panic!("failed with code {}, message: {}", e.code, e.message),
> >      }
> > +    common::clean(d);
> >      common::close(c);
> >  }
> 
> Why did you change the order of the two test methods ? It has created a
> big diff that hides what is actually being changed. Can you put them back
> to the original order, so we just see the relevant change.

No ideas I will rearrange that.

> 
> Regards,
> Daniel
> -- 
> |: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-            https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list