1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/fogdocker/requests/compute/container_action_tests.rb
Daniel Lobato b38f644f77 Docker: Support for logs/top operations
In order to test this properly, responses from the mock return values
closer to what the API actually returns. Examples are from Remote API
1.18.

downcasing hash keys cannot be performed on all Docker API operations so
now it will only be done where the top element is a hash. Logs, top, and
many others will not return a hash.
2014-10-16 12:43:02 +02:00

35 lines
1.3 KiB
Ruby

Shindo.tests("Fog::Compute[:fogdocker] | container_action request", 'fogdocker') do
compute = Fog::Compute[:fogdocker]
name = "fog-#{Time.now.to_i}"
response = compute.container_create(:name => name, 'image' => 'mattdm/fedora:f19','Cmd' => ['date'])
id = response['id']
tests("Start Container") do
response = compute.container_action(:id => id, :action => :start)
test("should be a kind of Hash") { response.kind_of? Hash }
test("should be running") { response['state_running'] == true }
end
tests("Stop Container") do
response = compute.container_action(:id => id, :action => :stop)
test("should be a kind of Hash") { response.kind_of? Hash }
end
tests("Kill Container") do
response = compute.container_action(:id => id, :action => :kill)
test("should be a kind of Hash") { response.kind_of? Hash }
test("should be stopped") { response['state_running'] == false }
end
tests("Top Container") do
response = compute.container_action(:id => id, :action => :top)
test("should be an Array") { response.kind_of? Array }
test("should be an array of processes") { !!(response.first['PID'] =~ /^\d+$/) }
end
tests("Logs Container") do
response = compute.container_action(:id => id, :action => :logs)
test("should be a String") { response.kind_of? String }
end
end