null+****@clear*****
null+****@clear*****
2010年 12月 17日 (金) 12:46:10 JST
Kouhei Sutou 2010-12-17 03:46:10 +0000 (Fri, 17 Dec 2010)
New Revision: 385b78b9917aeedfd64e54d0a70f8f0d0cce1f68
Log:
use meaningful tag name for table_list output XML. #757
Added files:
test/unit/core/test-command-table-list.c
Modified files:
lib/proc.c
test/unit/core/Makefile.am
Modified: lib/proc.c (+7 -7)
===================================================================
--- lib/proc.c 2010-12-16 14:05:25 +0000 (904d1f4)
+++ lib/proc.c 2010-12-17 03:46:10 +0000 (ea7f5e0)
@@ -936,28 +936,28 @@ proc_table_list(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_dat
if ((cur = grn_table_cursor_open(ctx, ctx->impl->db, NULL, 0, NULL, 0, 0, -1, 0))) {
grn_id id;
GRN_OUTPUT_ARRAY_OPEN("TABLE_LIST", -1);
- GRN_OUTPUT_ARRAY_OPEN("COLUMNS", 6);
- GRN_OUTPUT_ARRAY_OPEN("COLUMN", 2);
+ GRN_OUTPUT_ARRAY_OPEN("HEADER", 6);
+ GRN_OUTPUT_ARRAY_OPEN("PROPERTY", 2);
GRN_OUTPUT_CSTR("id");
GRN_OUTPUT_CSTR("UInt32");
GRN_OUTPUT_ARRAY_CLOSE();
- GRN_OUTPUT_ARRAY_OPEN("COLUMN", 2);
+ GRN_OUTPUT_ARRAY_OPEN("PROPERTY", 2);
GRN_OUTPUT_CSTR("name");
GRN_OUTPUT_CSTR("ShortText");
GRN_OUTPUT_ARRAY_CLOSE();
- GRN_OUTPUT_ARRAY_OPEN("COLUMN", 2);
+ GRN_OUTPUT_ARRAY_OPEN("PROPERTY", 2);
GRN_OUTPUT_CSTR("path");
GRN_OUTPUT_CSTR("ShortText");
GRN_OUTPUT_ARRAY_CLOSE();
- GRN_OUTPUT_ARRAY_OPEN("COLUMN", 2);
+ GRN_OUTPUT_ARRAY_OPEN("PROPERTY", 2);
GRN_OUTPUT_CSTR("flags");
GRN_OUTPUT_CSTR("ShortText");
GRN_OUTPUT_ARRAY_CLOSE();
- GRN_OUTPUT_ARRAY_OPEN("COLUMN", 2);
+ GRN_OUTPUT_ARRAY_OPEN("PROPERTY", 2);
GRN_OUTPUT_CSTR("domain");
GRN_OUTPUT_CSTR("ShortText");
GRN_OUTPUT_ARRAY_CLOSE();
- GRN_OUTPUT_ARRAY_OPEN("COLUMN", 2);
+ GRN_OUTPUT_ARRAY_OPEN("PROPERTY", 2);
GRN_OUTPUT_CSTR("range");
GRN_OUTPUT_CSTR("ShortText");
GRN_OUTPUT_ARRAY_CLOSE();
Modified: test/unit/core/Makefile.am (+2 -0)
===================================================================
--- test/unit/core/Makefile.am 2010-12-16 14:05:25 +0000 (cd9ec8d)
+++ test/unit/core/Makefile.am 2010-12-17 03:46:10 +0000 (592ce24)
@@ -41,6 +41,7 @@ noinst_LTLIBRARIES = \
test-table-sort-key-from-str.la \
test-inspect.la \
test-command-load.la \
+ test-command-table-list.la \
test-command-column-list.la \
test-command-select.la \
test-command-select-sort.la \
@@ -117,6 +118,7 @@ test_log_la_SOURCES = test-log.c
test_table_sort_key_from_str_la_SOURCES = test-table-sort-key-from-str.c
test_inspect_la_SOURCES = test-inspect.c
test_command_load_la_SOURCES = test-command-load.c
+test_command_table_list_la_SOURCES = test-command-table-list.c
test_command_column_list_la_SOURCES = test-command-column-list.c
test_command_select_la_SOURCES = test-command-select.c
test_command_select_sort_la_SOURCES = test-command-select-sort.c
Added: test/unit/core/test-command-table-list.c (+132 -0) 100644
===================================================================
--- /dev/null
+++ test/unit/core/test-command-table-list.c 2010-12-17 03:46:10 +0000 (1bab7f4)
@@ -0,0 +1,132 @@
+/* -*- c-basic-offset: 2; coding: utf-8 -*- */
+/*
+ Copyright (C) 2010 Kouhei Sutou <kou****@clear*****>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License version 2.1 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <gcutter.h>
+#include <glib/gstdio.h>
+
+#include "../lib/grn-assertions.h"
+
+#include <str.h>
+
+#define get(name) grn_ctx_get(context, name, strlen(name))
+
+void test_xml(void);
+
+static gchar *tmp_directory;
+static const gchar *database_path;
+
+static grn_ctx *context;
+static grn_obj *database;
+
+void
+cut_startup(void)
+{
+ tmp_directory = g_build_filename(grn_test_get_tmp_dir(),
+ "table-list",
+ NULL);
+}
+
+void
+cut_shutdown(void)
+{
+ g_free(tmp_directory);
+}
+
+static void
+remove_tmp_directory(void)
+{
+ cut_remove_path(tmp_directory, NULL);
+}
+
+void
+cut_setup(void)
+{
+ remove_tmp_directory();
+ g_mkdir_with_parents(tmp_directory, 0700);
+
+ context = g_new0(grn_ctx, 1);
+ grn_ctx_init(context, 0);
+
+ database_path = cut_build_path(tmp_directory, "database.groonga", NULL);
+ database = grn_db_create(context, database_path, NULL);
+}
+
+void
+cut_teardown(void)
+{
+ if (context) {
+ grn_ctx_fin(context);
+ g_free(context);
+ }
+
+ remove_tmp_directory();
+}
+
+void
+test_xml(void)
+{
+ assert_send_command("table_create Users TABLE_HASH_KEY ShortText");
+ assert_send_command("table_create Sites TABLE_PAT_KEY ShortText");
+ assert_send_command("table_create Tweets TABLE_NO_KEY");
+ cut_assert_equal_string(
+ cut_take_printf("<TABLE_LIST>\n"
+ "<HEADER>\n"
+ "<PROPERTY>\n"
+ "<TEXT>id</TEXT>\n"
+ "<TEXT>UInt32</TEXT></PROPERTY>\n"
+ "<PROPERTY>\n"
+ "<TEXT>name</TEXT>\n"
+ "<TEXT>ShortText</TEXT></PROPERTY>\n"
+ "<PROPERTY>\n"
+ "<TEXT>path</TEXT>\n"
+ "<TEXT>ShortText</TEXT></PROPERTY>\n"
+ "<PROPERTY>\n"
+ "<TEXT>flags</TEXT>\n"
+ "<TEXT>ShortText</TEXT></PROPERTY>\n"
+ "<PROPERTY>\n"
+ "<TEXT>domain</TEXT>\n"
+ "<TEXT>ShortText</TEXT></PROPERTY>\n"
+ "<PROPERTY>\n"
+ "<TEXT>range</TEXT>\n"
+ "<TEXT>ShortText</TEXT></PROPERTY></HEADER>\n"
+ "<TABLE>\n"
+ "<INT>%u</INT>\n"
+ "<TEXT>Sites</TEXT>\n"
+ "<TEXT>%s.0000101</TEXT>\n"
+ "<TEXT>TABLE_PAT_KEY|PERSISTENT</TEXT>\n"
+ "<TEXT>ShortText</TEXT>\n"
+ "<TEXT>null</TEXT></TABLE>\n"
+ "<TABLE>\n"
+ "<INT>%u</INT>\n"
+ "<TEXT>Tweets</TEXT>\n"
+ "<TEXT>%s.0000102</TEXT>\n"
+ "<TEXT>TABLE_NO_KEY|PERSISTENT</TEXT>\n"
+ "<TEXT>null</TEXT>\n"
+ "<TEXT>null</TEXT></TABLE>\n"
+ "<TABLE>\n"
+ "<INT>%u</INT>\n"
+ "<TEXT>Users</TEXT>\n"
+ "<TEXT>%s.0000100</TEXT>\n"
+ "<TEXT>TABLE_HASH_KEY|PERSISTENT</TEXT>\n"
+ "<TEXT>ShortText</TEXT>\n"
+ "<TEXT>null</TEXT></TABLE></TABLE_LIST>",
+ grn_obj_id(context, get("Sites")), database_path,
+ grn_obj_id(context, get("Tweets")), database_path,
+ grn_obj_id(context, get("Users")), database_path),
+ send_command("table_list --output_type xml"));
+}