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

added support for searching of images in fogdocker

This commit is contained in:
Dmitri Dolguikh 2014-10-13 16:25:14 +01:00
parent b18ffc9776
commit 7fa4e46c82
5 changed files with 46 additions and 1 deletions

View file

@ -25,6 +25,7 @@ module Fog
request :image_create
request :image_delete
request :image_get
request :image_search
class Mock
def initialize(options={})

View file

@ -14,6 +14,10 @@ module Fog
def get(id)
new service.image_get(id)
end
def image_search(query = {})
service.image_search(query)
end
end
end
end

View file

@ -0,0 +1,29 @@
module Fog
module Compute
class Fogdocker
class Real
def image_search(query = {})
Docker::Util.parse_json(Docker.connection.get('/images/search', query)).map do |image|
downcase_hash_keys(image)
end
end
end
class Mock
def image_search(query = {})
[
{"description" => "",
"is_official" => false,
"is_automated" => false,
"name" => "wma55/u1210sshd",
"star_count" => 0},
{"description" => "",
"is_official" => false,
"is_automated" => false,
"name" => "jdswinbank/sshd",
"star_count" => 0}
]
end
end
end
end
end

View file

@ -10,7 +10,7 @@ Shindo.tests('Fog::Compute[:fogdocker]', ['fogdocker']) do
tests("Compute requests") do
%w{ api_version container_all container_create container_delete container_get
container_action image_all image_create image_delete image_get }.each do |collection|
container_action image_all image_create image_delete image_get image_search }.each do |collection|
test("it should respond to #{collection}") { compute.respond_to? collection }
end
end

View file

@ -0,0 +1,11 @@
Shindo.tests("Fog::Compute[:fogdocker] | image_search request", 'fogdocker') do
compute = Fog::Compute[:fogdocker]
tests("Search images") do
response = compute.image_search('term' => 'test')
test("should be a kind of Array") { response.kind_of? Array}
test("Array elements should be a kind of Hash") { response.first.kind_of? Hash}
test("response elemetns should have a name") { !response.first['name'].nil? && !response.first['name'].empty? }
end
end