Exemplo n.º 1
0
static void
test_set_content_property_again(gs_grid_storage_t * gs)
{
	gs_error_t **err = NULL;
	gchar **result = NULL;

	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	hc_ul_content_from_file(gs, nameCont, "Content", "file_test.txt", err);
	gs_content_t *content = gs_get_content_from_path(container, "Content", err);

	char *props = "key1=value1";
	char *props2 = "key1=value2";

	hc_set_content_property(content, &props, err);
	hc_set_content_property(content, &props2, err);
	g_assert_true(err == NULL);

	hc_get_content_properties(content, &result, err);
	if (strcmp(result[0], "key1=value2"))
		g_test_fail();

	gs_content_free(content);
	test_end(gs, nameRef, container);
}
Exemplo n.º 2
0
gs_error_t *
hc_func_set_property(gs_grid_storage_t *hc, struct hc_url_s *url,
	char ** args)
{
	gs_error_t *e = NULL;
	gs_container_t *c = NULL;
	gs_content_t *content = NULL;

	c = gs_get_storage_container(hc, hc_url_get(url, HCURL_REFERENCE),
			NULL, 0, &e);
	if (NULL != c) {
		if (hc_url_has(url, HCURL_PATH)) {
			content = gs_get_content_from_path_and_version (c,
					hc_url_get(url, HCURL_PATH), hc_url_get(url, HCURL_VERSION),
					&e);
			if (NULL != content) {
				gchar **props = g_malloc0(sizeof(gchar*) * 2);
				props[0] = g_strdup_printf("%s=%s", args[0], args[1]);
				props[1] = NULL;
				hc_set_content_property(content, props, &e);
				gs_content_free(content);
				g_strfreev(props);
			}
		} else {
			e = hc_set_container_global_property(c, args[0], args[1]);
		}
		gs_container_free(c);
	}
	return e;
}
Exemplo n.º 3
0
static void
test_set_content_property_wrong(gs_grid_storage_t * gs)	// to be improved
{
	gs_error_t **err = NULL;
	gchar **result = NULL;

	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	hc_ul_content_from_file(gs, nameCont, "Content", "file_test.txt", err);
	gs_content_t *content = gs_get_content_from_path(container, "Content", err);

	char *props[] = { "wrong_property" };

	hc_set_content_property(content, props, err);
	if (err == NULL)
		g_test_fail();

	hc_get_content_properties(content, &result, err);

	gs_content_free(content);
	test_end(gs, nameRef, container);
}