fog-digitalocean 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -2
- data/README.md +1 -2
- data/lib/fog/bin/digitalocean.rb +30 -0
- data/lib/fog/digitalocean/compute.rb +27 -15
- data/lib/fog/digitalocean/models/compute/volume.rb +15 -0
- data/lib/fog/digitalocean/models/compute/volumes.rb +42 -0
- data/lib/fog/digitalocean/requests/compute/attach_volume.rb +122 -0
- data/lib/fog/digitalocean/requests/compute/create_server.rb +2 -0
- data/lib/fog/digitalocean/requests/compute/create_volume.rb +50 -0
- data/lib/fog/digitalocean/requests/compute/destroy_volume.rb +32 -0
- data/lib/fog/digitalocean/requests/compute/detach_volume.rb +121 -0
- data/lib/fog/digitalocean/requests/compute/get_image_details.rb +1 -1
- data/lib/fog/digitalocean/requests/compute/get_volume_details.rb +60 -0
- data/lib/fog/digitalocean/requests/compute/list_volume_actions.rb +64 -0
- data/lib/fog/digitalocean/requests/compute/list_volumes.rb +64 -0
- data/lib/fog/digitalocean/requests/compute/resize_volume.rb +65 -0
- data/lib/fog/digitalocean/version.rb +1 -1
- data/tests/digitalocean/requests/compute/attach_volume_tests.rb +10 -0
- data/tests/digitalocean/requests/compute/create_volume_tests.rb +10 -0
- data/tests/digitalocean/requests/{compute_v2 → compute}/list_ssh_keys_tests.rb +2 -2
- data/tests/digitalocean/requests/compute/list_volumes_tests.rb +23 -0
- metadata +21 -136
- data/benchs/each_provider.sh +0 -6
- data/benchs/each_service.sh +0 -6
- data/benchs/fog_vs.rb +0 -106
- data/benchs/load_times.rb +0 -37
- data/benchs/params.rb +0 -43
- data/benchs/parse_vs_push.rb +0 -67
- data/spec/fog/account_spec.rb +0 -14
- data/spec/fog/billing_spec.rb +0 -14
- data/spec/fog/bin/atmos_spec.rb +0 -33
- data/spec/fog/bin/aws_spec.rb +0 -98
- data/spec/fog/bin/baremetalcloud_spec.rb +0 -33
- data/spec/fog/bin/bluebox_spec.rb +0 -55
- data/spec/fog/bin/brightbox_spec.rb +0 -30
- data/spec/fog/bin/clodo_spec.rb +0 -9
- data/spec/fog/bin/cloudsigma_spec.rb +0 -9
- data/spec/fog/bin/cloudstack_spec.rb +0 -9
- data/spec/fog/bin/digitalocean_spec.rb +0 -9
- data/spec/fog/bin/dnsimple_spec.rb +0 -9
- data/spec/fog/bin/dnsmadeeasy_spec.rb +0 -9
- data/spec/fog/bin/dreamhost_spec.rb +0 -9
- data/spec/fog/bin/dynect_spec.rb +0 -9
- data/spec/fog/bin/ecloud_spec.rb +0 -10
- data/spec/fog/bin/fogdocker_spec.rb +0 -10
- data/spec/fog/bin/glesys_spec.rb +0 -10
- data/spec/fog/bin/gogrid_spec.rb +0 -10
- data/spec/fog/bin/google_spec.rb +0 -10
- data/spec/fog/bin/ibm_spec.rb +0 -10
- data/spec/fog/bin/internetarchive_spec.rb +0 -10
- data/spec/fog/bin/joyent_spec.rb +0 -10
- data/spec/fog/bin/linode_spec.rb +0 -10
- data/spec/fog/bin/local_spec.rb +0 -10
- data/spec/fog/bin/ninefold_spec.rb +0 -10
- data/spec/fog/bin/opennebula_spec.rb +0 -10
- data/spec/fog/bin/openstack_spec.rb +0 -10
- data/spec/fog/bin/openvz_spec.rb +0 -10
- data/spec/fog/bin/ovirt_spec.rb +0 -10
- data/spec/fog/bin/powerdns_spec.rb +0 -9
- data/spec/fog/bin/profitbricks_spec.rb +0 -10
- data/spec/fog/bin/rackspace_spec.rb +0 -10
- data/spec/fog/bin/rage4_spec.rb +0 -10
- data/spec/fog/bin/riakcs_spec.rb +0 -10
- data/spec/fog/bin/sakuracloud_spec.rb +0 -10
- data/spec/fog/bin/serverlove_spec.rb +0 -10
- data/spec/fog/bin/softlayer_spec.rb +0 -10
- data/spec/fog/bin/stormondemand_spec.rb +0 -10
- data/spec/fog/bin/vcloud_spec.rb +0 -10
- data/spec/fog/bin/vclouddirector_spec.rb +0 -10
- data/spec/fog/bin/vmfusion_spec.rb +0 -10
- data/spec/fog/bin/voxel_spec.rb +0 -10
- data/spec/fog/bin/vsphere_spec.rb +0 -10
- data/spec/fog/bin/xenserver_spec.rb +0 -10
- data/spec/fog/bin/zerigo_spec.rb +0 -10
- data/spec/fog/bin_spec.rb +0 -161
- data/spec/fog/cdn_spec.rb +0 -14
- data/spec/fog/compute_spec.rb +0 -19
- data/spec/fog/dns_spec.rb +0 -19
- data/spec/fog/identity_spec.rb +0 -14
- data/spec/fog/image_spec.rb +0 -14
- data/spec/fog/metering_spec.rb +0 -14
- data/spec/fog/monitoring_spec.rb +0 -14
- data/spec/fog/network_spec.rb +0 -14
- data/spec/fog/orchestration_spec.rb +0 -14
- data/spec/fog/storage_spec.rb +0 -14
- data/spec/fog/support_spec.rb +0 -14
- data/spec/fog/volume_spec.rb +0 -14
- data/spec/fog/vpn_spec.rb +0 -14
- data/spec/fog/xml/connection_spec.rb +0 -33
- data/spec/helpers/bin.rb +0 -34
- data/spec/spec_helper.rb +0 -18
data/benchs/each_provider.sh
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
# for each provider
|
4
|
-
grep -lr "< Fog::Service$" lib/fog | xargs -L1 dirname | sort | uniq | sed -e 's/lib\///' |
|
5
|
-
# trigger rubygem cost then benchmark the load time
|
6
|
-
xargs -I{} ruby -Ilib -rbenchmark -e 'Gem::Specification._all; puts "{}: #{Benchmark.realtime{require "{}" }}"'
|
data/benchs/each_service.sh
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
# for each service
|
4
|
-
grep -lr "< Fog::Service$" lib/fog | sed -e 's/lib\///' -e 's/.rb$//' |
|
5
|
-
# trigger rubygem cost then benchmark the load time
|
6
|
-
xargs -I{} ruby -Ilib -rbenchmark -e 'Gem::Specification._all; puts "{}: #{Benchmark.realtime{ require "{}" }}"'
|
data/benchs/fog_vs.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'aws/s3'
|
3
|
-
require 'benchmark'
|
4
|
-
require 'right_aws'
|
5
|
-
|
6
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
|
7
|
-
|
8
|
-
data = File.open(File.expand_path('~/.fog')).read
|
9
|
-
config = YAML.load(data)[:default]
|
10
|
-
fog = Fog::AWS::S3.new(
|
11
|
-
:aws_access_key_id => config[:aws_access_key_id],
|
12
|
-
:aws_secret_access_key => config[:aws_secret_access_key]
|
13
|
-
)
|
14
|
-
raws = RightAws::S3Interface.new(
|
15
|
-
config[:aws_access_key_id],
|
16
|
-
config[:aws_secret_access_key]
|
17
|
-
)
|
18
|
-
raws.logger.level = 3 # ERROR
|
19
|
-
awss3 = AWS::S3::Base.establish_connection!(
|
20
|
-
:access_key_id => config[:aws_access_key_id],
|
21
|
-
:secret_access_key => config[:aws_secret_access_key],
|
22
|
-
:persistent => true
|
23
|
-
)
|
24
|
-
|
25
|
-
TIMES = 10
|
26
|
-
|
27
|
-
Benchmark.bmbm(25) do |bench|
|
28
|
-
bench.report('fog.put_bucket') do
|
29
|
-
TIMES.times do |x|
|
30
|
-
fog.put_bucket("fogbench#{x}")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
bench.report('raws.create_bucket') do
|
34
|
-
TIMES.times do |x|
|
35
|
-
raws.create_bucket("rawsbench#{x}")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
bench.report('awss3::Bucket.create') do
|
39
|
-
TIMES.times do |x|
|
40
|
-
AWS::S3::Bucket.create("awss3bench#{x}")
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
bench.report('fog.put_object') do
|
45
|
-
TIMES.times do |x|
|
46
|
-
TIMES.times do |y|
|
47
|
-
file = File.open(File.dirname(__FILE__) + '/../spec/lorem.txt', 'r')
|
48
|
-
fog.put_object("fogbench#{x}", "lorem_#{y}", file)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
bench.report('raws.put') do
|
53
|
-
TIMES.times do |x|
|
54
|
-
TIMES.times do |y|
|
55
|
-
file = File.open(File.dirname(__FILE__) + '/../spec/lorem.txt', 'r')
|
56
|
-
raws.put("rawsbench#{x}", "lorem_#{y}", file)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
bench.report('awss3::S3Object.create') do
|
61
|
-
TIMES.times do |x|
|
62
|
-
TIMES.times do |y|
|
63
|
-
file = File.open(File.dirname(__FILE__) + '/../spec/lorem.txt', 'r')
|
64
|
-
AWS::S3::S3Object.create("lorem_#{y}", file, "awss3bench#{x}")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
bench.report('fog.delete_object') do
|
70
|
-
TIMES.times do |x|
|
71
|
-
TIMES.times do |y|
|
72
|
-
fog.delete_object("fogbench#{x}", "lorem_#{y}")
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
bench.report('raws.delete') do
|
77
|
-
TIMES.times do |x|
|
78
|
-
TIMES.times do |y|
|
79
|
-
raws.delete("rawsbench#{x}", "lorem_#{y}")
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
bench.report('awss3::S3Object.delete') do
|
84
|
-
TIMES.times do |x|
|
85
|
-
TIMES.times do |y|
|
86
|
-
AWS::S3::S3Object.delete("lorem_#{y}", "awss3bench#{x}")
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
bench.report('fog.delete_bucket') do
|
92
|
-
TIMES.times do |x|
|
93
|
-
fog.delete_bucket("fogbench#{x}")
|
94
|
-
end
|
95
|
-
end
|
96
|
-
bench.report('raws.delete_bucket') do
|
97
|
-
TIMES.times do |x|
|
98
|
-
raws.delete_bucket("rawsbench#{x}")
|
99
|
-
end
|
100
|
-
end
|
101
|
-
bench.report('awss3::Bucket.delete') do
|
102
|
-
TIMES.times do |x|
|
103
|
-
AWS::S3::Bucket.delete("awss3bench#{x}")
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
data/benchs/load_times.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'benchmark'
|
2
|
-
$LOAD_PATH << File.dirname(__FILE__) + '/../lib'
|
3
|
-
|
4
|
-
def time_in_fork(&block)
|
5
|
-
read, write = IO.pipe
|
6
|
-
Process.fork do
|
7
|
-
write.puts Benchmark.realtime{ block.call }
|
8
|
-
end
|
9
|
-
Process.wait
|
10
|
-
write.close
|
11
|
-
read.read.tap do
|
12
|
-
read.close
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class Array
|
17
|
-
def avg
|
18
|
-
map(&:to_f).inject(:+) / size
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def report(label, n = 10, &block)
|
23
|
-
puts label
|
24
|
-
puts "%.4f" % n.times.map{ time_in_fork &block }.avg
|
25
|
-
puts
|
26
|
-
end
|
27
|
-
|
28
|
-
# make rubygems load specifications now so the
|
29
|
-
# time is not included below.
|
30
|
-
Gem::Specification._all
|
31
|
-
|
32
|
-
N = 10
|
33
|
-
|
34
|
-
report("require fog:", N) { require 'fog' }
|
35
|
-
report("require fog/aws:", N) { require 'fog/aws' }
|
36
|
-
report("require fog/aws/compute:", N) { require 'fog/aws/compute' }
|
37
|
-
report("require fog/aws/core:", N) { require 'fog/aws/core'}
|
data/benchs/params.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'benchmark'
|
2
|
-
|
3
|
-
def hash(options)
|
4
|
-
result = "#{options.delete(:name)}"
|
5
|
-
for key, value in options
|
6
|
-
result << " #{key} => #{value} "
|
7
|
-
end
|
8
|
-
result
|
9
|
-
end
|
10
|
-
|
11
|
-
def optional(name, a = nil, b = nil, c = nil)
|
12
|
-
result = "#{name}"
|
13
|
-
options = { :a => a, :b => b, :c => c }
|
14
|
-
for key, value in options
|
15
|
-
result << " #{key} => #{value} "
|
16
|
-
end
|
17
|
-
result
|
18
|
-
end
|
19
|
-
|
20
|
-
COUNT = 100_000
|
21
|
-
data = "Content-Length: 100"
|
22
|
-
Benchmark.bmbm(25) do |bench|
|
23
|
-
bench.report('hash') do
|
24
|
-
COUNT.times do
|
25
|
-
hash({:name => 'name'})
|
26
|
-
end
|
27
|
-
end
|
28
|
-
bench.report('optional') do
|
29
|
-
COUNT.times do
|
30
|
-
optional('name')
|
31
|
-
end
|
32
|
-
end
|
33
|
-
bench.report('hash_with_option') do
|
34
|
-
COUNT.times do
|
35
|
-
hash({:name => 'name', :a => 'a', :b => 'b', :c => 'c'})
|
36
|
-
end
|
37
|
-
end
|
38
|
-
bench.report('optional_with_option') do
|
39
|
-
COUNT.times do
|
40
|
-
optional('name', :a => 'a', :b => 'b', :c => 'c')
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/benchs/parse_vs_push.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'benchmark'
|
2
|
-
require 'rubygems'
|
3
|
-
require 'nokogiri'
|
4
|
-
|
5
|
-
class Parser < Nokogiri::XML::SAX::Document
|
6
|
-
attr_reader :response
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
reset
|
10
|
-
end
|
11
|
-
|
12
|
-
def reset
|
13
|
-
@item = {}
|
14
|
-
@response = { :items => [] }
|
15
|
-
end
|
16
|
-
|
17
|
-
def characters(string)
|
18
|
-
@value ||= ''
|
19
|
-
@value << string.strip
|
20
|
-
end
|
21
|
-
|
22
|
-
def start_element(name, attrs = [])
|
23
|
-
@value = nil
|
24
|
-
end
|
25
|
-
|
26
|
-
def end_element(name)
|
27
|
-
case name
|
28
|
-
when 'item'
|
29
|
-
@response[:items] << @item
|
30
|
-
@item = {}
|
31
|
-
when 'key'
|
32
|
-
@item[:key] = value
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def value
|
37
|
-
@value.dup
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
data = <<-DATA
|
42
|
-
<items>
|
43
|
-
<item>
|
44
|
-
<key>value</key>
|
45
|
-
</item>
|
46
|
-
</items>
|
47
|
-
DATA
|
48
|
-
|
49
|
-
COUNT = 10_000
|
50
|
-
|
51
|
-
Benchmark.bmbm(25) do |bench|
|
52
|
-
bench.report('parse') do
|
53
|
-
COUNT.times do
|
54
|
-
parser = Parser.new
|
55
|
-
Nokogiri::XML::SAX::Parser.new(parser).parse(data)
|
56
|
-
parser.response
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
bench.report('push') do
|
61
|
-
COUNT.times do
|
62
|
-
parser = Parser.new
|
63
|
-
Nokogiri::XML::SAX::PushParser.new(parser).write(data, true)
|
64
|
-
parser.response
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
data/spec/fog/account_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Fog::Account do
|
4
|
-
Fog::Account.providers.each do |provider|
|
5
|
-
describe "when #{provider} is passed with no available credentials" do
|
6
|
-
it "returns ArgumentError" do
|
7
|
-
# Stub credentials so you still see errors where the tester really has credentials
|
8
|
-
Fog.stub :credentials, {} do
|
9
|
-
assert_raises(ArgumentError) { Fog::Account[provider] }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/spec/fog/billing_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Fog::Billing do
|
4
|
-
Fog::Billing.providers.each do |provider|
|
5
|
-
describe "when #{provider} is passed with no available credentials" do
|
6
|
-
it "returns ArgumentError" do
|
7
|
-
# Stub credentials so you still see errors where the tester really has credentials
|
8
|
-
Fog.stub :credentials, {} do
|
9
|
-
assert_raises(ArgumentError) { Fog::Billing[provider] }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/spec/fog/bin/atmos_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "fog/bin"
|
3
|
-
require "helpers/bin"
|
4
|
-
|
5
|
-
describe Atmos do
|
6
|
-
include Fog::BinSpec
|
7
|
-
|
8
|
-
let(:subject) { Atmos }
|
9
|
-
|
10
|
-
describe "#services" do
|
11
|
-
it "includes all services" do
|
12
|
-
assert_includes Atmos.services, :storage
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#class_for" do
|
17
|
-
describe "when requesting storage service" do
|
18
|
-
it "returns correct class" do
|
19
|
-
assert_equal Fog::Storage::Atmos, Atmos.class_for(:storage)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#[]" do
|
25
|
-
describe "when requesting storage service" do
|
26
|
-
it "returns instance" do
|
27
|
-
Fog::Storage::Atmos.stub(:new, "instance") do
|
28
|
-
assert_equal "instance", Atmos[:storage]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/spec/fog/bin/aws_spec.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "fog/bin"
|
3
|
-
require "helpers/bin"
|
4
|
-
|
5
|
-
describe AWS do
|
6
|
-
include Fog::BinSpec
|
7
|
-
|
8
|
-
let(:subject) { AWS }
|
9
|
-
|
10
|
-
KEY_CLASS_MAPPING = {
|
11
|
-
:auto_scaling => Fog::AWS::AutoScaling,
|
12
|
-
:beanstalk => Fog::AWS::ElasticBeanstalk,
|
13
|
-
:cdn => Fog::CDN::AWS,
|
14
|
-
:cloud_formation => Fog::AWS::CloudFormation,
|
15
|
-
:cloud_watch => Fog::AWS::CloudWatch,
|
16
|
-
:compute => Fog::Compute::AWS,
|
17
|
-
:data_pipeline => Fog::AWS::DataPipeline,
|
18
|
-
:ddb => Fog::AWS::DynamoDB,
|
19
|
-
:dynamodb => Fog::AWS::DynamoDB,
|
20
|
-
:dns => Fog::DNS::AWS,
|
21
|
-
:elasticache => Fog::AWS::Elasticache,
|
22
|
-
:elb => Fog::AWS::ELB,
|
23
|
-
:emr => Fog::AWS::EMR,
|
24
|
-
:glacier => Fog::AWS::Glacier,
|
25
|
-
:iam => Fog::AWS::IAM,
|
26
|
-
:redshift => Fog::AWS::Redshift,
|
27
|
-
:sdb => Fog::AWS::SimpleDB,
|
28
|
-
:simpledb => Fog::AWS::SimpleDB,
|
29
|
-
:ses => Fog::AWS::SES,
|
30
|
-
:sqs => Fog::AWS::SQS,
|
31
|
-
:eu_storage => Fog::Storage::AWS,
|
32
|
-
:storage => Fog::Storage::AWS,
|
33
|
-
:rds => Fog::AWS::RDS,
|
34
|
-
:sns => Fog::AWS::SNS,
|
35
|
-
:sts => Fog::AWS::STS
|
36
|
-
}
|
37
|
-
|
38
|
-
describe "#services" do
|
39
|
-
it "includes all services" do
|
40
|
-
assert_includes AWS.services, :auto_scaling
|
41
|
-
assert_includes AWS.services, :beanstalk
|
42
|
-
assert_includes AWS.services, :cdn
|
43
|
-
assert_includes AWS.services, :cloud_formation
|
44
|
-
assert_includes AWS.services, :cloud_watch
|
45
|
-
assert_includes AWS.services, :compute
|
46
|
-
assert_includes AWS.services, :data_pipeline
|
47
|
-
assert_includes AWS.services, :dynamodb
|
48
|
-
assert_includes AWS.services, :dns
|
49
|
-
assert_includes AWS.services, :elasticache
|
50
|
-
assert_includes AWS.services, :elb
|
51
|
-
assert_includes AWS.services, :emr
|
52
|
-
assert_includes AWS.services, :glacier
|
53
|
-
assert_includes AWS.services, :iam
|
54
|
-
assert_includes AWS.services, :redshift
|
55
|
-
assert_includes AWS.services, :rds
|
56
|
-
assert_includes AWS.services, :simpledb
|
57
|
-
assert_includes AWS.services, :ses
|
58
|
-
assert_includes AWS.services, :sqs
|
59
|
-
assert_includes AWS.services, :storage
|
60
|
-
assert_includes AWS.services, :sns
|
61
|
-
assert_includes AWS.services, :sts
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "#class_for" do
|
66
|
-
describe "when key exists" do
|
67
|
-
it "maps to correct class" do
|
68
|
-
KEY_CLASS_MAPPING.each do |key, klass|
|
69
|
-
assert_equal klass, AWS.class_for(key)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "when key does not exist" do
|
75
|
-
it "raises ArgumentError" do
|
76
|
-
assert_raises(ArgumentError) { AWS.class_for(:bad_key) }
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe "#[]" do
|
82
|
-
describe "when service is recognised" do
|
83
|
-
it "returns correct instance" do
|
84
|
-
KEY_CLASS_MAPPING.each do |key, klass|
|
85
|
-
klass.stub(:new, "#{klass} instance") do
|
86
|
-
assert_equal "#{klass} instance", AWS[key]
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "when service is not recognised" do
|
93
|
-
it "raises ArgumentError" do
|
94
|
-
assert_raises(ArgumentError) { AWS[:bad_service] }
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "fog/bin"
|
3
|
-
require "helpers/bin"
|
4
|
-
|
5
|
-
describe BareMetalCloud do
|
6
|
-
include Fog::BinSpec
|
7
|
-
|
8
|
-
let(:subject) { BareMetalCloud }
|
9
|
-
|
10
|
-
describe "#services" do
|
11
|
-
it "includes all services" do
|
12
|
-
assert_includes BareMetalCloud.services, :compute
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#class_for" do
|
17
|
-
describe "when requesting storage service" do
|
18
|
-
it "returns correct class" do
|
19
|
-
assert_equal Fog::Compute::BareMetalCloud, BareMetalCloud.class_for(:compute)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#[]" do
|
25
|
-
describe "when requesting compute service" do
|
26
|
-
it "returns instance" do
|
27
|
-
Fog::Compute::BareMetalCloud.stub(:new, "instance") do
|
28
|
-
assert_equal "instance", BareMetalCloud[:compute]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|