Navigation Menu

Skip to content

Commit

Permalink
Normalize result of table_list and column_list commands
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 24, 2014
1 parent 86a5993 commit bb6635c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/drntest/response-normalizer.rb
Expand Up @@ -80,6 +80,7 @@ def normalize_errors(errors)

def normalize_groonga_command_response!(response)
normalize_groonga_command_header!(response[0])
normalize_groonga_command_body!(response[1..-1])
end

def normalized_start_time
Expand All @@ -96,6 +97,37 @@ def normalize_groonga_command_header!(header)
header[2] = normalized_elapsed if valid_elapsed?(header[2])
end

def normalize_groonga_command_body!(body)
return unless body.is_a?(Array)

case @request["type"]
when "table_list"
normalize_groonga_table_list_command_body!(body[1..-1])
when "column_list"
normalize_groonga_column_list_command_body!(body[1..-1])
end
end

TABLE_PATH_COLUMN_INDEX = 2
def normalize_groonga_table_list_command_body!(tables)
return unless tables.is_a?(Array)
tables.each do |table|
if table[TABLE_PATH_COLUMN_INDEX].is_a?(String)
table[TABLE_PATH_COLUMN_INDEX] = "/path/to/table"
end
end
end

COLUMN_PATH_COLUMN_INDEX = 2
def normalize_groonga_column_list_command_body!(columns)
return unless columns.is_a?(Array)
columns.each do |column|
if column[COLUMN_PATH_COLUMN_INDEX].is_a?(String)
column[COLUMN_PATH_COLUMN_INDEX] = "/path/to/column"
end
end
end

def normalize_search_command_response!(response)
response.each do |query_name, result|
if valid_elapsed?(result["elapsedTime"])
Expand Down

0 comments on commit bb6635c

Please sign in to comment.