[libgovirt] tests: Fix errors related to switching to meson and rest-1.0
- From: Eduardo de Barros Lima <eblima src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgovirt] tests: Fix errors related to switching to meson and rest-1.0
- Date: Fri, 19 Aug 2022 19:12:50 +0000 (UTC)
commit 91eabec447fd0a51365f9986162caea304719148
Author: Eduardo Lima (Etrunko) <etrunko redhat com>
Date: Mon Aug 15 16:03:32 2022 -0300
tests: Fix errors related to switching to meson and rest-1.0
Disable certificates test due to change of behavior in librest.
https://gitlab.gnome.org/GNOME/librest/-/issues/16
https://gitlab.gnome.org/GNOME/librest/-/merge_requests/28
Signed-off-by: Eduardo Lima (Etrunko) <etrunko redhat com>
tests/mock-httpd.c | 2 +-
tests/test-govirt.c | 28 +++++++++++++++++-----------
2 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/tests/mock-httpd.c b/tests/mock-httpd.c
index f84786f..322eecd 100644
--- a/tests/mock-httpd.c
+++ b/tests/mock-httpd.c
@@ -129,7 +129,7 @@ govirt_httpd_run (gpointer user_data)
NULL);
soup_server_listen_local (server, mock_httpd->port, 0, &error);
}
- g_assert (error == NULL);
+ g_assert_no_error (error);
soup_server_add_handler (server, NULL,
server_callback, mock_httpd, NULL);
diff --git a/tests/test-govirt.c b/tests/test-govirt.c
index f11a1f1..0f3a1ba 100644
--- a/tests/test-govirt.c
+++ b/tests/test-govirt.c
@@ -52,6 +52,10 @@ static void test_govirt_https_ca(void)
GError *error = NULL;
GovirtMockHttpd *httpd;
+ /*FIXME: https://gitlab.gnome.org/GNOME/librest/-/issues/16
+ https://gitlab.gnome.org/GNOME/librest/-/merge_requests/28
+ */
+ return;
httpd = govirt_mock_httpd_new(GOVIRT_HTTPS_PORT);
govirt_mock_httpd_add_request(httpd, "GET", "/ovirt-engine/api", "<api></api>");
govirt_mock_httpd_start(httpd);
@@ -69,13 +73,15 @@ static void test_govirt_https_ca(void)
g_object_unref(proxy);
g_unsetenv("GOVIRT_NO_SSL_STRICT");
+ g_test_expect_message("Rest", G_LOG_LEVEL_WARNING,
+ "*runtime check failed*");
g_test_expect_message("libgovirt", G_LOG_LEVEL_WARNING,
"Error while getting collection: Unacceptable TLS certificate");
proxy = ovirt_proxy_new("localhost:" G_STRINGIFY(GOVIRT_HTTPS_PORT));
api = ovirt_proxy_fetch_api(proxy, &error);
g_test_assert_expected_messages();
g_assert_null(api);
- g_assert_error(error, REST_PROXY_ERROR, REST_PROXY_ERROR_SSL);
+ g_assert_error(error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE);
g_assert_cmpstr(error->message, ==, "Unacceptable TLS certificate");
g_clear_error(&error);
@@ -256,25 +262,25 @@ static void govirt_mock_httpd_add_vms(GovirtMockHttpd *httpd, MockOvirtVm vms[],
/* Create individual /api/vms/$uuid entry points */
for (i = 0; i < count; i++) {
MockOvirtVm *vm = &vms[i];
- char *href;
-
- href = g_strdup_printf("/ovirt-engine/api/vms/%s", vm->uuid);
+ char *href = g_strdup_printf("/ovirt-engine/api/vms/%s", vm->uuid);
if (vm->xml != NULL) {
govirt_mock_httpd_add_request(httpd, "GET", href, vm->xml);
} else if (vm->filename != NULL) {
- char *body;
-
- /* uninit_use_in_call: Using uninitialized value "body" when calling "g_file_get_contents". */
- if (!g_file_get_contents(g_test_build_filename(G_TEST_DIST, srcdir, "mock-xml-data",
vm->filename, NULL),
- &body, NULL, NULL)) {
+ char *body = NULL;
+ char *path = NULL;
+ gboolean ret;
+ path = g_build_filename(srcdir, "mock-xml-data", vm->filename, NULL);
+ ret = g_file_get_contents(path, &body, NULL, NULL);
+ g_clear_pointer(&path, g_free);
+ if (!ret) {
g_warn_if_reached();
continue;
}
govirt_mock_httpd_add_request(httpd, "GET", href, body);
- g_free(body);
+ g_clear_pointer(&body, g_free);
}
- g_free(href);
+ g_clear_pointer(&href, g_free);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]