tests for fields and describe analytics requests

This commit is contained in:
Kevin Olbrich 2014-01-04 02:21:39 +00:00
parent db1520952d
commit d78c5b541d
4 changed files with 48 additions and 0 deletions

View File

@ -84,6 +84,19 @@ module Fog
'requested_duration' => 30,
'requested_end_time' => Time.now.utc - 570
}
when :fields
{
'fields' => {
'zonename' => {
'label' => 'zone name',
'type' => 'string'
},
'pid' => {
'label' => 'process identifier',
'type' => 'string'
}
}
}
else
{}
end

View File

@ -10,6 +10,15 @@ module Fog
)
end
end
class Mock
def describe_analytics
response = Excon::Response.new
response.status = 200
response.body = self.data[:fields]
response
end
end
end
end
end

View File

@ -0,0 +1,13 @@
Shindo.tests("Fog::Joyent[:analytics] | fields", %w{joyent}) do
@analytics = Fog::Joyent[:analytics]
@fields = @analytics.fields
tests('#all').succeeds do
@fields.all
end
tests('#new').succeeds do
@fields.new(['apache', { 'label' => 'Apache', 'type' => 'string' }])
end
end

View File

@ -0,0 +1,13 @@
Shindo.tests("Fog::Joyent[:analytics] | instrumentation", %w{joyent analytics instrumentation }) do
model_tests(Fog::Joyent[:analytics].instrumentations, {:joyent_module => 'cpu', :stat => 'usage'}, true)
@analytics = Fog::Joyent[:analytics]
@instrumentation = @analytics.instrumentations.first
tests('#values') do
@values = @instrumentation.values(Time.now.utc.to_i - 600, 5)
returns(Array) { @values.class }
returns(Fog::Joyent::Analytics::Value) { @values.first.class }
end
end