[libgovirt] resource: Fix ovirt_resource_init_from_xml_real precondition
- From: Eduardo de Barros Lima <eblima src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgovirt] resource: Fix ovirt_resource_init_from_xml_real precondition
- Date: Mon, 18 Sep 2017 13:18:52 +0000 (UTC)
commit 434382cfb5e257d531ad287c3815de639a76e6b0
Author: Christophe Fergeau <cfergeau redhat com>
Date: Mon Sep 11 15:01:59 2017 +0200
resource: Fix ovirt_resource_init_from_xml_real precondition
When ovirt_resource_init_from_xml_real is called, the current value of
OvirtResource::xml-node is not very relevant, what matters is whether
the passed in xml node is NULL or not.
This updates the test-govirt test case to call
ovirt_resource_refresh(ovirt_vm_get_cluster()) as this triggers this
precondition failure.
govirt/ovirt-resource.c | 2 +-
tests/test-govirt.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
index 0f4a129..ad5e8ca 100644
--- a/govirt/ovirt-resource.c
+++ b/govirt/ovirt-resource.c
@@ -422,7 +422,7 @@ static gboolean ovirt_resource_init_from_xml_real(OvirtResource *resource,
*/
is_api = OVIRT_IS_API(resource);
- g_return_val_if_fail(resource->priv->xml != NULL, FALSE);
+ g_return_val_if_fail(node != NULL, FALSE);
guid = rest_xml_node_get_attr(node, "id");
if ((guid == NULL) && !is_api) {
diff --git a/tests/test-govirt.c b/tests/test-govirt.c
index 84126d7..f090d2b 100644
--- a/tests/test-govirt.c
+++ b/tests/test-govirt.c
@@ -290,6 +290,8 @@ static void test_govirt_parse_vm_host_cluster(void)
httpd = govirt_mock_httpd_new(GOVIRT_HTTPS_PORT);
govirt_mock_httpd_add_vms(httpd, &mock_vm, 1);
+ govirt_mock_httpd_add_request(httpd, "GET",
"/ovirt-engine/api/clusters/00000000-0000-0000-0001-000000000000",
+ "<cluster
href=\"/ovirt-engine/api/clusters/00000000-0000-0000-0001-000000000000\"
id=\"00000000-0000-0000-0001-000000000000\"/>");
govirt_mock_httpd_start(httpd);
proxy = ovirt_proxy_new("localhost:" G_STRINGIFY(GOVIRT_HTTPS_PORT));
@@ -322,6 +324,8 @@ static void test_govirt_parse_vm_host_cluster(void)
g_object_get(G_OBJECT(cluster), "guid", &guid, NULL);
g_assert_cmpstr(guid, ==, "00000000-0000-0000-0001-000000000000");
g_free(guid);
+ ovirt_resource_refresh(OVIRT_RESOURCE(cluster), proxy, &error);
+ g_assert_no_error(error);
g_object_unref(cluster);
g_object_unref(vm);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]