1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

add tests for instrumentations

This commit is contained in:
Kevin Olbrich 2014-01-03 14:25:59 -05:00
parent a3016d6f50
commit 619a66216c
6 changed files with 56 additions and 1 deletions

View file

@ -5,6 +5,8 @@ class Joyent < Fog::Bin
case key case key
when :compute when :compute
Fog::Compute::Joyent Fog::Compute::Joyent
when :analytics
Fog::Joyent::Analytics
else else
raise ArgumentError, "Unrecognized service: #{key}" raise ArgumentError, "Unrecognized service: #{key}"
end end
@ -16,6 +18,8 @@ class Joyent < Fog::Bin
when :compute when :compute
Fog::Logger.warning("Joyent[:compute] is not recommended, use Compute[:joyent] for portability") Fog::Logger.warning("Joyent[:compute] is not recommended, use Compute[:joyent] for portability")
Fog::Compute.new(:provider => 'Joyent') Fog::Compute.new(:provider => 'Joyent')
when :analytics
Fog::Joyent::Analytics.new
else else
raise ArgumentError, "Unrecognized service: #{key.inspect}" raise ArgumentError, "Unrecognized service: #{key.inspect}"
end end

View file

@ -50,7 +50,30 @@ module Fog
class Mock class Mock
def self.data def self.data
@data ||= Hash.new do |hash, key| @data ||= Hash.new do |hash, key|
hash[key] = {} hash[key] =case key
when :instrumentation
{ 'module' => "cpu",
'stat' => "usage",
'predicate' => {},
'decomposition' => ["zonename"],
'value-dimension' => 2,
'value-arity' => "discrete-decomposition",
'enabled' => true,
'retention-time' => 86400,
'idle-max' => 86400,
'transformations' => [],
'nsources' => 3,
'granularity' => 30,
'persist-data' => false,
'crtime' => 1388690982000,
'value-scope' => "point",
'id' => "63",
'uris' =>
[{ "uri" => "/#{@joyent_username}/analytics/instrumentations/63/value/raw",
"name" => "value_raw" }] }
else
{}
end
end end
end end
@ -61,6 +84,8 @@ module Fog
def initialize(options = {}) def initialize(options = {})
@joyent_username = options[:joyent_username] || Fog.credentials[:joyent_username] @joyent_username = options[:joyent_username] || Fog.credentials[:joyent_username]
@joyent_password = options[:joyent_password] || Fog.credentials[:joyent_password] @joyent_password = options[:joyent_password] || Fog.credentials[:joyent_password]
@joyent_url = 'https://us-sw-1.api.joyentcloud.com'
@joyent_version = '~7'
end end
def request(opts) def request(opts)

View file

@ -11,6 +11,15 @@ module Fog
) )
end end
end end
class Mock
def create_instrumentation(values = {})
response = Excon::Response.new
response.status = 200
response.body = self.data[:instrumentation]
response
end
end
end end
end end
end end

View file

@ -10,6 +10,14 @@ module Fog
) )
end end
end end
class Mock
def delete_instrumentation(id)
response = Excon::Response.new
response.status = 204
response
end
end
end end
end end
end end

View file

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