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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@xxxxxxxxxxxxx>
---
 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);
 }
 
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux