Esempio n. 1
0
void
test_register_too_long_name(void)
{
  GString *long_name;
  const gchar *full_path;
  const gchar *error_message_without_path;
  const gchar *error_message_without_name;
  gint i, max_name_length;

  long_name = gcut_take_new_string(NULL);
  max_name_length = (PATH_MAX - strlen(plugins_dir) - 1) - 1;
  for (i = 0; i < max_name_length; i++) {
    g_string_append_c(long_name, 'x');
  }
  full_path = cut_take_string(g_build_filename(plugins_dir,
                                               long_name->str,
                                               NULL));
  error_message_without_path = "too long plugin path: <";
  grn_test_assert_send_command_error(
    context,
    GRN_FILENAME_TOO_LONG,
    cut_take_printf("%s%.*s",
                    error_message_without_path,
                    (int)(GRN_CTX_MSGSIZE -
                          strlen(error_message_without_path) -
                          1),
                    full_path),
    cut_take_printf("register %s", long_name->str));

  g_string_append_c(long_name, 'x');
  full_path = cut_take_string(g_build_filename(plugins_dir,
                                               long_name->str,
                                               NULL));
  error_message_without_name =
    cut_take_printf("plugin name is too long: %d (max: %d) <",
                    (int)(long_name->len),
                    max_name_length);
  grn_test_assert_send_command_error(
    context,
    GRN_INVALID_ARGUMENT,
    cut_take_printf("%s%.*s",
                    error_message_without_name,
                    (int)(GRN_CTX_MSGSIZE -
                          strlen(error_message_without_name) -
                          1),
                    full_path),
    cut_take_printf("register %s", long_name->str));
}
Esempio n. 2
0
void
test_invalid_start_with_symbol(void)
{
    const gchar *table_list_result;

    table_list_result =
        cut_take_printf("["
                        "[[\"id\",\"UInt32\"],"
                        "[\"name\",\"ShortText\"],"
                        "[\"path\",\"ShortText\"],"
                        "[\"flags\",\"ShortText\"],"
                        "[\"domain\",\"ShortText\"],"
                        "[\"range\",\"ShortText\"]],"
                        "[256,"
                        "\"Authors\","
                        "\"%s.0000100\","
                        "\"TABLE_PAT_KEY|PERSISTENT\","
                        "\"ShortText\","
                        "\"null\"]]",
                        database_path);

    assert_send_command("table_create Authors TABLE_PAT_KEY ShortText");
    cut_assert_equal_string(table_list_result, send_command("table_list"));
    grn_test_assert_send_command_error(context,
                                       GRN_INVALID_ARGUMENT,
                                       "JSON must start with '[' or '{': <invalid>",
                                       "load "
                                       "--table Authors "
                                       "--columns '_key' "
                                       "--values 'invalid'");
    cut_assert_equal_string(table_list_result, send_command("table_list"));
}
Esempio n. 3
0
void
test_no_table_name(void)
{
    grn_test_assert_send_command_error(
        context,
        GRN_INVALID_ARGUMENT,
        "[table][record][delete] table name isn't specified",
        "delete");
}
void
test_no_operator_and_parentheses_column(void)
{
  grn_test_assert_send_command_error(
    context,
    GRN_INVALID_ARGUMENT,
    "invalid function: <\"groonga\">",
    "select Sites --filter \"_key != \\\"groonga\\\" ()\"");
}
void
test_nonexistent_table(void)
{
  grn_test_assert_send_command_error(
    context,
    GRN_INVALID_ARGUMENT,
    "[column][create]: table doesn't exist: <Users>",
    "column_create Users name COLUMN_SCALAR ShortText");
}
Esempio n. 6
0
void
test_nonexistent_table(void)
{
    grn_test_assert_send_command_error(
        context,
        GRN_INVALID_ARGUMENT,
        "[table][record][delete] table doesn't exist: <nonexistent>",
        "delete nonexistent");
}
Esempio n. 7
0
void
test_key_and_id(void)
{
    grn_test_assert_send_command_error(
        context,
        GRN_INVALID_ARGUMENT,
        "[table][record][delete] can't use both key and id: "
        "table: <Users>, key: <mori>, id: <1>",
        "delete Users --key mori --id 1");
}
Esempio n. 8
0
void
test_no_selector(void)
{
    grn_test_assert_send_command_error(
        context,
        GRN_INVALID_ARGUMENT,
        "[table][record][delete] either key, id or filter must be specified: "
        "table: <Users>",
        "delete Users");
}
Esempio n. 9
0
void
test_id_and_filter(void)
{
    grn_test_assert_send_command_error(
        context,
        GRN_INVALID_ARGUMENT,
        "[table][record][delete] can't use both id and filter: "
        "table: <Users>, id: <1>, filter: <true>",
        "delete Users --id 1 --filter true");
}
Esempio n. 10
0
void
test_invalid_id(void)
{
    grn_test_assert_send_command_error(
        context,
        GRN_INVALID_ARGUMENT,
        "[table][record][delete] id should be number: "
        "table: <Users>, id: <1x2>, detail: <1|x|2>",
        "delete Users --id \"1x2\"");
}
Esempio n. 11
0
void
test_invalid_name(void)
{
  grn_test_assert_send_command_error(
    context,
    GRN_INVALID_ARGUMENT,
    "[table][create] name can't start with '_' and "
    "contains only 0-9, A-Z, a-z, #, @, - or _: <_Users>",
    "table_create _Users");
}
Esempio n. 12
0
void
test_invalid_filter(void)
{
    grn_test_assert_send_command_error(
        context,
        GRN_SYNTAX_ERROR,
        "[table][record][delete] failed to parse filter: "
        "table: <Users>, filter: <$>, detail: <Syntax error! ($)>",
        "delete Users --filter \"$\"");
}
void
test_nonexistent_expansion_column(gconstpointer data)
{
  grn_test_assert_send_command_error(
    context,
    GRN_INVALID_ARGUMENT,
    "nonexistent query expansion column: <Synonyms.nonexistent>",
    "select Diaries --match_columns content --query groonga "
    "--query_expansion Synonyms.nonexistent");
}
Esempio n. 14
0
void
test_key_and_filter(void)
{
    grn_test_assert_send_command_error(
        context,
        GRN_INVALID_ARGUMENT,
        "[table][record][delete] can't use both key and filter: "
        "table: <Users>, key: <mori>, filter: <true>",
        "delete Users --key mori --filter true");
}
Esempio n. 15
0
void
test_all_selector(void)
{
    grn_test_assert_send_command_error(
        context,
        GRN_INVALID_ARGUMENT,
        "[table][record][delete] "
        "record selector must be one of key, id and filter: "
        "table: <Users>, key: <mori>, id: <1>, filter: <true>",
        "delete Users --key mori --id 1 --filter \"true\"");
}
Esempio n. 16
0
void
test_nonexistent(void)
{
  grn_test_assert_send_command_error(
    context,
    GRN_INVALID_ARGUMENT,
    "invalid sort key: <nonexistent>(<_score,nonexistent>)",
    "select Sites "
    "--sortby \"_score,nonexistent\" "
    "--output_columns \"_key\"");
}
Esempio n. 17
0
void
test_score_without_query(void)
{
  grn_test_assert_send_command_error(
    context,
    GRN_INVALID_ARGUMENT,
    "invalid sort key: <_score>(<_score>)",
    "select Sites "
    "--sortby \"_score\" "
    "--output_columns \"_key\"");
}
Esempio n. 18
0
void
test_nonexistent_table_name(void)
{
    grn_test_assert_send_command_error(context,
                                       GRN_INVALID_ARGUMENT,
                                       "nonexistent table: <Users>",
                                       "load --table Users\n"
                                       "[\n"
                                       "[\"_key\": \"alice\"]\n"
                                       "]");
}
Esempio n. 19
0
void
test_invalid_name(void)
{
  assert_send_command("table_create Users");
  grn_test_assert_send_command_error(
    context,
    GRN_INVALID_ARGUMENT,
    "[column][create]: name can't start with '_' and 0-9, "
    "and contains only 0-9, A-Z, a-z, or _: <_name>",
    "column_create Users _name COLUMN_SCALAR ShortText");
}
void
test_nonexistent(void)
{
  grn_test_assert_send_command_error(
    context,
    GRN_INVALID_ARGUMENT,
    "[select][sort] failed to parse: <_score,nonexistent>: "
    "invalid sort key: <nonexistent>: table:<Sites> keys:<_score,nonexistent>",
    "select Sites "
    "--sortby \"_score,nonexistent\" "
    "--output_columns \"_key\"");
}
Esempio n. 21
0
void
test_in_rectangle_over_border(void)
{
  grn_test_assert_send_command_error(
    context,
    GRN_FUNCTION_NOT_IMPLEMENTED,
    "geo_in_rectangle(): negative coordinate is not implemented.",
    "select Shops "
    "--sortby '+name' "
    "--output_columns 'name, location' "
    "--filter 'geo_in_rectangle(location, "
    "\"35.73360x-139.7394\", \"-35.62614x139.7714\")'");
}
Esempio n. 22
0
void
test_invalid_table_name(void)
{
    grn_test_assert_send_command_error(
        context,
        GRN_INVALID_ARGUMENT,
        "[table][load]: name can't start with '_' and 0-9, "
        "and contains only 0-9, A-Z, a-z, or _: <_Users>",
        "load --table _Users\n"
        "[\n"
        "[\"_key\": \"alice\"]\n"
        "]");
}
Esempio n. 23
0
void
test_no_key_table_without_columns(void)
{
    assert_send_command("table_create Numbers TABLE_NO_KEY");
    grn_test_assert_send_command_error(context,
                                       GRN_INVALID_ARGUMENT,
                                       "column name must be string: <1>",
                                       "load --table Numbers\n"
                                       "[\n"
                                       "[1],\n"
                                       "[2],\n"
                                       "[3]\n"
                                       "]");
}
Esempio n. 24
0
void
test_score_drilldown_without_query(void)
{
  grn_test_assert_send_command_error(
    context,
    GRN_INVALID_ARGUMENT,
    "invalid sort key: <_score>(<_score>)",
    "select Bookmarks "
    "--sortby \"_score\" "
    "--output_columns \"site._key, user._key\" "
    "--drilldown \"site user rank\" "
    "--drilldown_output_columns \"_key, _nsubrecs\" "
    "--drilldown_sortby \"_key\"");
}
Esempio n. 25
0
void
test_nonexistent_columns(void)
{
    assert_send_command("table_create Users TABLE_NO_KEY");
    assert_send_command("column_create Users name COLUMN_SCALAR ShortText");
    grn_test_assert_send_command_error(context,
                                       GRN_INVALID_ARGUMENT,
                                       "nonexistent column: <nonexistent>",
                                       "load "
                                       "--table Users "
                                       "--columns nonexistent "
                                       "--values "
                                       "'[[\"nonexistent column value\"]]'");
}
Esempio n. 26
0
void
test_in_rectangle_over_bottom_right_longitude(void)
{
  grn_test_assert_send_command_error(
    context,
    GRN_INVALID_ARGUMENT,
    "geo_in_rectangle(): bottom right point's longitude is too big: "
    "<648000000>(max:648000000): "
    "(128640960,503061840) (128254104,648",
    "select Shops "
    "--sortby '+name' "
    "--output_columns 'name, location' "
    "--filter "
    "'geo_in_rectangle(location, \"35.73360x139.7394\", \"35.62614x180.0\")'");
}
Esempio n. 27
0
void
test_in_rectangle_over_top_left_latitude(void)
{
  grn_test_assert_send_command_error(
    context,
    GRN_INVALID_ARGUMENT,
    "geo_in_rectangle(): top left point's latitude is too big: "
    "<324000000>(max:324000000): "
    "(324000000,503061840) (128254104,50317704",
    "select Shops "
    "--sortby '+name' "
    "--output_columns 'name, location' "
    "--filter "
    "'geo_in_rectangle(location, \"90.0x139.7394\", \"35.62614x139.7714\")'");
}