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:
parent
b18ffc9776
commit
7fa4e46c82
5 changed files with 46 additions and 1 deletions
|
@ -25,6 +25,7 @@ module Fog
|
|||
request :image_create
|
||||
request :image_delete
|
||||
request :image_get
|
||||
request :image_search
|
||||
|
||||
class Mock
|
||||
def initialize(options={})
|
||||
|
|
|
@ -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
|
||||
|
|
29
lib/fog/fogdocker/requests/compute/image_search.rb
Normal file
29
lib/fog/fogdocker/requests/compute/image_search.rb
Normal 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
|
|
@ -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
|
||||
|
|
11
tests/fogdocker/requests/compute/image_search_tests.rb
Normal file
11
tests/fogdocker/requests/compute/image_search_tests.rb
Normal 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
|
Loading…
Add table
Reference in a new issue