Navigation Menu

Skip to content

Commit

Permalink
test: Fix test cases for column_list command
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 23, 2014
1 parent 4ce4412 commit 6be1051
Showing 1 changed file with 56 additions and 10 deletions.
66 changes: 56 additions & 10 deletions test/unit/plugins/groonga/test_column_list.rb
Expand Up @@ -68,19 +68,49 @@ def test_fix_column
Groonga::Schema.define(:context => @context) do |schema|
schema.create_table("Books", :type => :hash)
schema.change_table("Books") do |table|
table.column("title", "ShortText", :type => :scalar)
table.column("age", "UInt32", :type => :scalar)
end
end
response = process(:column_list,
{"table" => "Books"})
expected = [
COLUMNS_HEADER,
[257, "title", path, "fix", "COLUMN_SCALAR", "Foo", "ShortText", []],
[257,
"age",
@database_path.to_s + ".0000101",
"fix",
"COLUMN_SCALAR",
"Books",
"UInt32",
[]],
]
assert_equal(expected, response.last)
end

def test_var_column
Groonga::Schema.define(:context => @context) do |schema|
schema.create_table("Books", :type => :hash)
schema.change_table("Books") do |table|
table.column("title", "ShortText", :type => :scalar)
end
end
response = process(:column_list,
{"table" => "Books"})
expected = [
COLUMNS_HEADER,
[257,
"title",
@database_path.to_s + ".0000101",
"var",
"COLUMN_SCALAR",
"Books",
"ShortText",
[]],
]
assert_equal(expected, response.last)
end

def test_vector_column
Groonga::Schema.define(:context => @context) do |schema|
schema.create_table("Books", :type => :hash)
schema.change_table("Books") do |table|
Expand All @@ -91,7 +121,14 @@ def test_var_column
{"table" => "Books"})
expected = [
COLUMNS_HEADER,
[257, "authors", path, "var", "COLUMN_VECTOR", "Foo", "ShortText", []],
[257,
"authors",
@database_path.to_s + ".0000101",
"var",
"COLUMN_VECTOR",
"Books",
"ShortText",
[]],
]
assert_equal(expected, response.last)
end
Expand All @@ -108,15 +145,24 @@ def test_index_column
{"table" => "Books"})
expected = [
COLUMNS_HEADER,
[257, "title", path, "fix", "COLUMN_SCALAR", "Foo", "ShortText", []],
[258, "entry_title", path, "index", "COLUMN_INDEX", "Foo", "Foo", ["Foo.age"]],
[258,
"entry_title",
@database_path.to_s + ".0000102",
"index",
"COLUMN_INDEX",
"Books",
"Books",
["title"]],
[257,
"title",
@database_path.to_s + ".0000101",
"var",
"COLUMN_SCALAR",
"Books",
"ShortText",
[]],
]
assert_equal(expected, response.last)
end

private
def path
@context.database.path
end
end
end

0 comments on commit 6be1051

Please sign in to comment.