1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Fix error in assumption about TaskRecord queries

Task records as returned by the Query API have 'name' parameter
equal to the 'operation_name' parameter of the Model object (and
OperationName value of the get_task request)

This commit documents that difference in the test, and corrects
the get_execute_query Mock to mirror the behaviour.
This commit is contained in:
Mike Pountney 2014-09-23 22:39:24 +01:00
parent 45dcf01d9e
commit 2186bf73ef
2 changed files with 7 additions and 7 deletions

View file

@ -357,8 +357,8 @@ module Fog
data_type = :tasks
data[data_type].each do |id, dr|
r = {}
if name.nil? || dr[:name] == name
r[:name] = dr[:name]
if name.nil? || dr[:operation_name] == name
r[:name] = dr[:operation_name]
r[:href] = make_href("task/#{id}")
if dr[:end_time]
r[:endDate] = dr[:end_time].strftime('%Y-%m-%dT%H:%M:%S%z')

View file

@ -7,7 +7,6 @@ Shindo.tests('Compute::VcloudDirector | tasks', ['vclouddirector']) do
if Fog.mocking?
# add a bunch of tasks
50.times do
type = 'bogus'
task_id = @service.enqueue_task(
"Bogus Task",
'BogusTaskName',
@ -42,13 +41,14 @@ Shindo.tests('Compute::VcloudDirector | tasks', ['vclouddirector']) do
end
# We should also be able to find tasks via the Query API
# NB: Query name == task.operation_name
tests("Compute::VcloudDirector | tasks", ['find_by_query']) do
tests('we can retrieve :name without lazy loading').returns(task.name) do
query_task = tasks.find_by_query(:filter => "name==#{task.name}").first
tests('we can retrieve :name without lazy loading').returns(task.operation_name) do
query_task = tasks.find_by_query(:filter => "name==#{task.operation_name}").first
query_task.attributes[:name]
end
tests('by name').returns(task.name) do
query_task = tasks.find_by_query(:filter => "name==#{task.name}").first
tests('by name').returns(task.operation_name) do
query_task = tasks.find_by_query(:filter => "name==#{task.operation_name}").first
query_task.name
end
end