mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
64 lines
2.1 KiB
Ruby
64 lines
2.1 KiB
Ruby
![]() |
Shindo.tests('Fog::Rackspace::AutoScale | webhook_tests', ['rackspace', 'rackspace_autoscale']) do
|
||
|
pending if Fog.mocking?
|
||
|
service = Fog::Rackspace::AutoScale.new :rackspace_region => :ord
|
||
|
|
||
|
@launch_config = begin
|
||
|
Fog::Rackspace::AutoScale::LaunchConfig.new({
|
||
|
:service => @service,
|
||
|
:group => self
|
||
|
}).merge_attributes(LAUNCH_CONFIG_OPTIONS)
|
||
|
end
|
||
|
|
||
|
@group_config = begin
|
||
|
Fog::Rackspace::AutoScale::GroupConfig.new({
|
||
|
:service => @service,
|
||
|
:group => self
|
||
|
}).merge_attributes(GROUP_CONFIG_OPTIONS)
|
||
|
end
|
||
|
|
||
|
@group_id = service.create_group(@launch_config, @group_config, POLICIES_OPTIONS).body['group']['id']
|
||
|
|
||
|
@policy_id = service.create_policy(@group_id, POLICY_OPTIONS).body['policies'][0]['id']
|
||
|
|
||
|
tests('success') do
|
||
|
tests('#create webhook').formats(201) do
|
||
|
response = service.create_webhook(@group_id, @policy_id, WEBHOOK_OPTIONS)
|
||
|
@webhook_id = response.body['webhooks'][0]['id']
|
||
|
response.data[:status]
|
||
|
end
|
||
|
|
||
|
tests('#view webhook').formats(WEBHOOK_FORMAT) do
|
||
|
response = service.get_webhook(@group_id, @policy_id, @webhook_id)
|
||
|
response.body['webhook']
|
||
|
end
|
||
|
|
||
|
tests('#update webhook').formats(204) do
|
||
|
response = service.update_webhook(@group_id, @policy_id, @webhook_id, {'name' => 'new', 'metadata' => {}} )
|
||
|
response.data[:status]
|
||
|
end
|
||
|
|
||
|
tests('#delete webhook').formats(204) do
|
||
|
response = service.delete_webhook(@group_id, @policy_id, @webhook_id)
|
||
|
response.data[:status]
|
||
|
end
|
||
|
end
|
||
|
|
||
|
tests('failure') do
|
||
|
tests('#create webhook').raises(Fog::Rackspace::AutoScale::BadRequest) do
|
||
|
service.create_webhook(@group_id, @policy_id, {})
|
||
|
end
|
||
|
|
||
|
tests('#view webhook').raises(Fog::Rackspace::AutoScale::NotFound) do
|
||
|
service.get_webhook(@group_id, @policy_id, 123)
|
||
|
end
|
||
|
|
||
|
tests('#update webhook').raises(Fog::Rackspace::AutoScale::BadRequest) do
|
||
|
service.update_webhook(@group_id, @policy_id, @webhook_id, {})
|
||
|
end
|
||
|
|
||
|
tests('#delete webhook').raises(Fog::Rackspace::AutoScale::NotFound) do
|
||
|
service.delete_webhook(@group_id, @policy_id, 123)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|