1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00
fog--fog-aws/tests/models/cloud_watch/metric_statistics_tests.rb
2015-01-02 09:42:20 -08:00

51 lines
1.6 KiB
Ruby

Shindo.tests("AWS::CloudWatch | metric_statistics", ['aws', 'cloudwatch']) do
tests('success') do
pending if Fog.mocking?
instanceId = 'i-420c352f'
metricName = 'DiskReadBytes'
namespace = 'AWS/EC2'
startTime = (Time.now-600).iso8601
endTime = Time.now.iso8601
period = 60
statisticTypes = ['Minimum','Maximum','Sum','SampleCount','Average']
tests("#all").succeeds do
@statistics = Fog::AWS[:cloud_watch].metric_statistics.all({'Statistics' => statisticTypes, 'StartTime' => startTime, 'EndTime' => endTime, 'Period' => period, 'MetricName' => metricName, 'Namespace' => namespace, 'Dimensions' => [{'Name' => 'InstanceId', 'Value' => instanceId}]})
end
tests("#all_not_empty").returns(true) do
@statistics.length > 0
end
new_attributes = {
:namespace => 'Custom/Test',
:metric_name => 'ModelTest',
:value => 9,
:unit => 'None'
}
tests('#new').returns(new_attributes) do
Fog::AWS[:cloud_watch].metric_statistics.new(new_attributes).attributes
end
tests('#create').returns(new_attributes) do
Fog::AWS[:cloud_watch].metric_statistics.create(new_attributes).attributes
end
stats_set_attributes = {
:namespace => 'Custom/Test',
:metric_name => 'ModelTest',
:minimum => 0,
:maximum => 4,
:sum => 10,
:sample_count => 5,
:average => 2,
:unit => 'None'
}
tests('#create_stats_set').returns(stats_set_attributes) do
Fog::AWS[:cloud_watch].metric_statistics.create(stats_set_attributes).attributes
end
end
end