mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
keep mocked data on class (new instances will share data) and provide reset_data function
This commit is contained in:
parent
506647b411
commit
962169950a
63 changed files with 259 additions and 336 deletions
|
@ -2,6 +2,15 @@ module Fog
|
|||
module AWS
|
||||
class EC2
|
||||
|
||||
if Fog.mocking?
|
||||
def self.data
|
||||
@data
|
||||
end
|
||||
def self.reset_data
|
||||
@data = { :deleted_at => {}, :addresses => {}, :key_pairs => {}, :security_groups => {}, :volumes => {} }
|
||||
end
|
||||
end
|
||||
|
||||
def self.reload
|
||||
current_directory = File.dirname(__FILE__)
|
||||
load "#{current_directory}/../connection.rb"
|
||||
|
@ -72,10 +81,11 @@ module Fog
|
|||
load "#{requests_directory}/run_instances.rb"
|
||||
load "#{requests_directory}/terminate_instances.rb"
|
||||
# TODO: require "#{requests_directory}/unmonitor_instances.rb"
|
||||
end
|
||||
|
||||
if Fog.mocking?
|
||||
attr_accessor :data
|
||||
if Fog.mocking?
|
||||
reset_data
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Initialize connection to EC2
|
||||
|
@ -103,10 +113,6 @@ module Fog
|
|||
@port = options[:port] || 443
|
||||
@scheme = options[:scheme] || 'https'
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
|
||||
if Fog.mocking?
|
||||
@data = { :deleted_at => {}, :addresses => {}, :key_pairs => {}, :security_groups => {}, :volumes => {} }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -49,9 +49,9 @@ else
|
|||
|
||||
def copy_object(source_bucket_name, source_object_name, target_bucket_name, target_object_name, options = {})
|
||||
response = Fog::Response.new
|
||||
source_bucket = @data[:buckets][source_bucket_name]
|
||||
source_bucket = Fog::AWS::S3.data[:buckets][source_bucket_name]
|
||||
source_object = source_bucket && source_bucket[:objects][source_object_name]
|
||||
target_bucket = @data[:buckets][target_bucket_name]
|
||||
target_bucket = Fog::AWS::S3.data[:buckets][target_bucket_name]
|
||||
|
||||
if source_object && target_bucket
|
||||
response.status = 200
|
||||
|
|
|
@ -33,7 +33,7 @@ else
|
|||
|
||||
def delete_bucket(bucket_name)
|
||||
response = Fog::Response.new
|
||||
if @data[:buckets].delete(bucket_name)
|
||||
if Fog::AWS::S3.data[:buckets].delete(bucket_name)
|
||||
response.status = 204
|
||||
else
|
||||
response.status = 404
|
||||
|
|
|
@ -35,7 +35,7 @@ else
|
|||
|
||||
def delete_object(bucket_name, object_name)
|
||||
response = Fog::Response.new
|
||||
if bucket = @data[:buckets][bucket_name]
|
||||
if bucket = Fog::AWS::S3.data[:buckets][bucket_name]
|
||||
response.status = 204
|
||||
bucket[:objects].delete(object_name)
|
||||
else
|
||||
|
|
|
@ -61,7 +61,7 @@ else
|
|||
|
||||
def get_bucket(bucket_name, options = {})
|
||||
response = Fog::Response.new
|
||||
if bucket = @data[:buckets][bucket_name]
|
||||
if bucket = Fog::AWS::S3.data[:buckets][bucket_name]
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'Contents' => bucket[:objects].values.map do |object|
|
||||
|
|
|
@ -36,7 +36,7 @@ else
|
|||
|
||||
def get_bucket_location(bucket_name)
|
||||
response = Fog::Response.new
|
||||
if bucket = @data[:buckets][bucket_name]
|
||||
if bucket = Fog::AWS::S3.data[:buckets][bucket_name]
|
||||
response.status = 200
|
||||
response.body = {'LocationConstraint' => bucket['LocationConstraint'] }
|
||||
else
|
||||
|
|
|
@ -49,7 +49,7 @@ else
|
|||
|
||||
def get_object(bucket_name, object_name, options = {})
|
||||
response = Fog::Response.new
|
||||
if (bucket = @data[:buckets][bucket_name]) && (object = bucket[:objects][object_name])
|
||||
if (bucket = Fog::AWS::S3.data[:buckets][bucket_name]) && (object = bucket[:objects][object_name])
|
||||
if options['If-Match'] && options['If-Match'] != object['ETag']
|
||||
response.status = 412
|
||||
elsif options['If-Modified-Since'] && options['If-Modified-Since'] > Time.parse(object['LastModified'])
|
||||
|
|
|
@ -36,7 +36,7 @@ else
|
|||
|
||||
def get_request_payment(bucket_name)
|
||||
response = Fog::Response.new
|
||||
if bucket = @data[:buckets][bucket_name]
|
||||
if bucket = Fog::AWS::S3.data[:buckets][bucket_name]
|
||||
response.status = 200
|
||||
response.body = { 'Payer' => bucket['Payer'] }
|
||||
else
|
||||
|
|
|
@ -39,7 +39,7 @@ else
|
|||
def get_service
|
||||
response = Fog::Response.new
|
||||
response.headers['Status'] = 200
|
||||
buckets = @data[:buckets].values.map do |bucket|
|
||||
buckets = Fog::AWS::S3.data[:buckets].values.map do |bucket|
|
||||
bucket.reject do |key, value|
|
||||
!['CreationDate', 'Name'].include?(key)
|
||||
end
|
||||
|
|
|
@ -58,7 +58,7 @@ else
|
|||
else
|
||||
bucket['LocationConstraint'] = ''
|
||||
end
|
||||
@data[:buckets][bucket_name] = bucket
|
||||
Fog::AWS::S3.data[:buckets][bucket_name] = bucket
|
||||
response
|
||||
end
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ else
|
|||
def put_object(bucket_name, object_name, object, options = {})
|
||||
file = parse_file(object)
|
||||
response = Fog::Response.new
|
||||
if (bucket = @data[:buckets][bucket_name])
|
||||
if (bucket = Fog::AWS::S3.data[:buckets][bucket_name])
|
||||
response.status = 200
|
||||
bucket[:objects][object_name] = {
|
||||
:body => file[:body],
|
||||
|
|
|
@ -38,7 +38,7 @@ else
|
|||
|
||||
def put_request_payment(bucket_name, payer)
|
||||
response = Fog::Response.new
|
||||
if bucket = @data[:buckets][bucket_name]
|
||||
if bucket = Fog::AWS::S3.data[:buckets][bucket_name]
|
||||
response.status = 200
|
||||
bucket['Payer'] = payer
|
||||
else
|
||||
|
|
|
@ -2,6 +2,15 @@ module Fog
|
|||
module AWS
|
||||
class S3
|
||||
|
||||
if Fog.mocking?
|
||||
def self.reset_data
|
||||
@data = { :buckets => {} }
|
||||
end
|
||||
def self.data
|
||||
@data
|
||||
end
|
||||
end
|
||||
|
||||
def self.reload
|
||||
current_directory = File.dirname(__FILE__)
|
||||
load "#{current_directory}/../collection.rb"
|
||||
|
@ -37,10 +46,10 @@ module Fog
|
|||
load "#{requests_directory}/put_bucket.rb"
|
||||
load "#{requests_directory}/put_object.rb"
|
||||
load "#{requests_directory}/put_request_payment.rb"
|
||||
end
|
||||
|
||||
if Fog.mocking?
|
||||
attr_accessor :data
|
||||
if Fog.mocking?
|
||||
reset_data
|
||||
end
|
||||
end
|
||||
|
||||
# Initialize connection to S3
|
||||
|
@ -68,10 +77,6 @@ module Fog
|
|||
@port = options[:port] || 443
|
||||
@scheme = options[:scheme] || 'https'
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
|
||||
if Fog.mocking?
|
||||
@data = { :buckets => {} }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -2,16 +2,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
|
||||
describe 'EC2.allocate_address' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.release_address(@public_ip)
|
||||
ec2.release_address(@public_ip)
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.allocate_address
|
||||
actual = ec2.allocate_address
|
||||
actual.body['requestId'].should be_a(String)
|
||||
@public_ip = actual.body['publicIp']
|
||||
actual.body['publicIp'].should be_a(String)
|
||||
|
|
|
@ -3,18 +3,17 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.associate_address' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
||||
@public_ip = @ec2.allocate_address.body['publicIp']
|
||||
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
||||
@public_ip = ec2.allocate_address.body['publicIp']
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.release_address(@public_ip)
|
||||
@ec2.terminate_instances([@instance_id])
|
||||
ec2.release_address(@public_ip)
|
||||
ec2.terminate_instances([@instance_id])
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.associate_address(@instance_id, @public_ip)
|
||||
actual = ec2.associate_address(@instance_id, @public_ip)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
[false, true].should include(actual.body['return'])
|
||||
end
|
||||
|
|
|
@ -3,24 +3,23 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.attach_volume' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@instance_id = @ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
|
||||
@volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
|
||||
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
eventually do
|
||||
@ec2.detach_volume(@volume_id)
|
||||
ec2.detach_volume(@volume_id)
|
||||
end
|
||||
eventually do
|
||||
@ec2.delete_volume(@volume_id)
|
||||
@ec2.terminate_instances([@instance_id])
|
||||
ec2.delete_volume(@volume_id)
|
||||
ec2.terminate_instances([@instance_id])
|
||||
end
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
eventually(128) do
|
||||
actual = @ec2.attach_volume(@volume_id, @instance_id, '/dev/sdh')
|
||||
actual = ec2.attach_volume(@volume_id, @instance_id, '/dev/sdh')
|
||||
actual.body['attachTime'].should be_a(Time)
|
||||
actual.body['device'].should be_a(String)
|
||||
actual.body['instanceId'].should be_a(String)
|
||||
|
|
|
@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.authorize_security_group_ingress' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
||||
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.delete_security_group('fog_security_group')
|
||||
ec2.delete_security_group('fog_security_group')
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.authorize_security_group_ingress({
|
||||
actual = ec2.authorize_security_group_ingress({
|
||||
'FromPort' => 80,
|
||||
'GroupName' => 'fog_security_group',
|
||||
'IpProtocol' => 'tcp',
|
||||
|
|
|
@ -2,16 +2,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
|
||||
describe 'EC2.create_key_pair' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.delete_key_pair('fog_key_pair')
|
||||
ec2.delete_key_pair('fog_key_pair')
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.create_key_pair('fog_key_pair')
|
||||
actual = ec2.create_key_pair('fog_key_pair')
|
||||
actual.body['keyFingerprint'].should be_a(String)
|
||||
actual.body['keyMaterial'].should be_a(String)
|
||||
actual.body['keyName'].should be_a(String)
|
||||
|
@ -20,7 +16,7 @@ describe 'EC2.create_key_pair' do
|
|||
|
||||
it "should raise a BadRequest when the key pair already exists" do
|
||||
lambda {
|
||||
@ec2.create_key_pair('fog_key_pair')
|
||||
ec2.create_key_pair('fog_key_pair')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,23 +2,19 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
|
||||
describe 'EC2.create_security_group' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.delete_security_group('fog_security_group')
|
||||
ec2.delete_security_group('fog_security_group')
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
||||
actual = ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
||||
actual.body['requestId'].should be_a(String)
|
||||
[false, true].should include(actual.body['return'])
|
||||
end
|
||||
|
||||
it "should raise a BadRequest error when the security group already exists" do
|
||||
lambda {
|
||||
@ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
||||
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.create_snapshot' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.delete_volume(@volume_id)
|
||||
ec2.delete_volume(@volume_id)
|
||||
eventually do
|
||||
@ec2.delete_snapshot(@snapshot_id)
|
||||
ec2.delete_snapshot(@snapshot_id)
|
||||
end
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.create_snapshot(@volume_id)
|
||||
actual = ec2.create_snapshot(@volume_id)
|
||||
actual.body['progress'].should be_a(String)
|
||||
@snapshot_id = actual.body['snapshotId']
|
||||
actual.body['snapshotId'].should be_a(String)
|
||||
|
|
|
@ -2,16 +2,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
|
||||
describe 'EC2.create_volume' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.delete_volume(@volume_id)
|
||||
ec2.delete_volume(@volume_id)
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.create_volume('us-east-1a', 1)
|
||||
actual = ec2.create_volume('us-east-1a', 1)
|
||||
actual.body['availabilityZone'].should be_a(String)
|
||||
actual.body['createTime'].should be_a(Time)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
|
|
|
@ -3,18 +3,17 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.delete_key_pair' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@ec2.create_key_pair('fog_key_pair')
|
||||
ec2.create_key_pair('fog_key_pair')
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.delete_key_pair('fog_key_pair')
|
||||
actual = ec2.delete_key_pair('fog_key_pair')
|
||||
actual.body['requestId'].should be_a(String)
|
||||
[false, true].should include(actual.body['return'])
|
||||
end
|
||||
|
||||
it "should not raise an error if the key pair does not exist" do
|
||||
@ec2.delete_key_pair('not_a_key_pair')
|
||||
ec2.delete_key_pair('not_a_key_pair')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.delete_security_group' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
||||
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.delete_security_group('fog_security_group')
|
||||
actual = ec2.delete_security_group('fog_security_group')
|
||||
actual.body['requestId'].should be_a(String)
|
||||
[false, true].should include(actual.body['return'])
|
||||
end
|
||||
|
||||
it "should raise a BadRequest error if the security group does not exist" do
|
||||
lambda {
|
||||
@ec2.delete_security_group('fog_not_a_security_group')
|
||||
ec2.delete_security_group('fog_not_a_security_group')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,18 +3,17 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.delete_snapshot' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
@snapshot_id = @ec2.create_snapshot(@volume_id).body['snapshotId']
|
||||
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
@snapshot_id = ec2.create_snapshot(@volume_id).body['snapshotId']
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.delete_volume(@volume_id)
|
||||
ec2.delete_volume(@volume_id)
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
eventually do
|
||||
actual = @ec2.delete_snapshot(@snapshot_id)
|
||||
actual = ec2.delete_snapshot(@snapshot_id)
|
||||
unless actual.body.empty?
|
||||
actual.body['requestId'].should be_a(String)
|
||||
[false, true].should include(actual.body['return'])
|
||||
|
|
|
@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.create_volume' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.delete_volume(@volume_id)
|
||||
actual = ec2.delete_volume(@volume_id)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
actual.body['return'].should == true
|
||||
end
|
||||
|
||||
it "should raise a BadRequest error if volume does not exist" do
|
||||
lambda {
|
||||
@ec2.release_address('vol-00000000')
|
||||
ec2.release_address('vol-00000000')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,23 +3,22 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.describe_addresses' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@public_ip = @ec2.allocate_address.body['publicIp']
|
||||
@public_ip = ec2.allocate_address.body['publicIp']
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.release_address(@public_ip)
|
||||
ec2.release_address(@public_ip)
|
||||
end
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
actual = @ec2.describe_addresses
|
||||
actual = ec2.describe_addresses
|
||||
actual.body['requestId'].should be_a(String)
|
||||
item = actual.body['addressesSet'].select {|address| address['publicIp'] == @public_ip}
|
||||
item.should_not be_nil
|
||||
end
|
||||
|
||||
it "should return proper attributes for specific ip" do
|
||||
actual = @ec2.describe_addresses(@public_ip)
|
||||
actual = ec2.describe_addresses(@public_ip)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
item = actual.body['addressesSet'].select {|address| address['publicIp'] == @public_ip}
|
||||
item.should_not be_nil
|
||||
|
@ -27,7 +26,7 @@ describe 'EC2.describe_addresses' do
|
|||
|
||||
it "should raise a BadRequest error if ip does not exist" do
|
||||
lambda {
|
||||
@ec2.describe_addresses('127.0.0.1')
|
||||
ec2.describe_addresses('127.0.0.1')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,12 +2,8 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
|
||||
describe 'EC2.describe_availability_zones' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
end
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
actual = @ec2.describe_availability_zones
|
||||
actual = ec2.describe_availability_zones
|
||||
zone = actual.body['availabilityZoneInfo'].first
|
||||
zone['regionName'].should be_a(String)
|
||||
zone['zoneName'].should be_a(String)
|
||||
|
@ -15,7 +11,7 @@ describe 'EC2.describe_availability_zones' do
|
|||
end
|
||||
|
||||
it "should return proper attribute with params" do
|
||||
actual = @ec2.describe_availability_zones(['us-east-1a'])
|
||||
actual = ec2.describe_availability_zones(['us-east-1a'])
|
||||
zone = actual.body['availabilityZoneInfo'].first
|
||||
zone['regionName'].should be_a(String)
|
||||
zone['zoneName'].should be_a(String)
|
||||
|
|
|
@ -2,12 +2,8 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
|
||||
describe 'EC2.describe_images' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
end
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
actual = @ec2.describe_images
|
||||
actual = ec2.describe_images
|
||||
actual.body['requestId'].should be_a(String)
|
||||
image = actual.body['imagesSet'].first
|
||||
image['architecture'].should be_a(String)
|
||||
|
@ -23,7 +19,7 @@ describe 'EC2.describe_images' do
|
|||
end
|
||||
|
||||
it "should return proper attributes with params" do
|
||||
actual = @ec2.describe_images('ImageId' => 'ami-5ee70037')
|
||||
actual = ec2.describe_images('ImageId' => 'ami-5ee70037')
|
||||
actual.body['requestId'].should be_a(String)
|
||||
image = actual.body['imagesSet'].first
|
||||
image['architecture'].should be_a(String)
|
||||
|
|
|
@ -3,18 +3,17 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.describe_instances' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
run_instances = @ec2.run_instances('ami-5ee70037', 1, 1).body
|
||||
run_instances = ec2.run_instances('ami-5ee70037', 1, 1).body
|
||||
@instance_id = run_instances['instancesSet'].first['instanceId']
|
||||
@reservation_id = run_instances['reservationId']
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.terminate_instances([@instance_id])
|
||||
ec2.terminate_instances([@instance_id])
|
||||
end
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
actual = @ec2.describe_instances
|
||||
actual = ec2.describe_instances
|
||||
reservation = actual.body['reservationSet'].select {|reservation| reservation['reservationId'] == @reservation_id}.first
|
||||
reservation['groupSet'].should be_an(Array)
|
||||
reservation['groupSet'].first.should be_a(String)
|
||||
|
@ -44,7 +43,7 @@ describe 'EC2.describe_instances' do
|
|||
end
|
||||
|
||||
it "should return proper attributes with params" do
|
||||
actual = @ec2.describe_instances(@instance_id)
|
||||
actual = ec2.describe_instances(@instance_id)
|
||||
reservation = actual.body['reservationSet'].select {|reservation| reservation['reservationId'] == @reservation_id}.first
|
||||
reservation['groupSet'].should be_an(Array)
|
||||
reservation['groupSet'].first.should be_a(String)
|
||||
|
|
|
@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.describe_key_pairs' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@ec2.create_key_pair('key_name')
|
||||
ec2.create_key_pair('key_name')
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.delete_key_pair('key_name')
|
||||
ec2.delete_key_pair('key_name')
|
||||
end
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
actual = @ec2.describe_key_pairs
|
||||
actual = ec2.describe_key_pairs
|
||||
actual.body['keySet'].should be_an(Array)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
key_pair = actual.body['keySet'].select {|key| key['keyName'] == 'key_name' }.first
|
||||
|
@ -21,7 +20,7 @@ describe 'EC2.describe_key_pairs' do
|
|||
end
|
||||
|
||||
it "should return proper attributes with params" do
|
||||
actual = @ec2.describe_key_pairs('key_name')
|
||||
actual = ec2.describe_key_pairs('key_name')
|
||||
actual.body['keySet'].should be_an(Array)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
key_pair = actual.body['keySet'].select {|key| key['keyName'] == 'key_name' }.first
|
||||
|
@ -31,7 +30,7 @@ describe 'EC2.describe_key_pairs' do
|
|||
|
||||
it "should raise a BadRequest error if the key does not exist" do
|
||||
lambda {
|
||||
@ec2.describe_key_pairs('not_a_key_name')
|
||||
ec2.describe_key_pairs('not_a_key_name')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,19 +2,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
|
||||
describe 'EC2.describe_availability_zones' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
end
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
actual = @ec2.describe_regions
|
||||
actual = ec2.describe_regions
|
||||
zone = actual.body['regionInfo'].first
|
||||
zone['regionEndpoint'].should be_a(String)
|
||||
zone['regionName'].should be_a(String)
|
||||
end
|
||||
|
||||
it "should return proper attribute with params" do
|
||||
actual = @ec2.describe_regions(['us-east-1'])
|
||||
actual = ec2.describe_regions(['us-east-1'])
|
||||
zone = actual.body['regionInfo'].first
|
||||
zone['regionEndpoint'].should be_a(String)
|
||||
zone['regionName'].should be_a(String)
|
||||
|
|
|
@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.describe_security_groups' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
||||
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.delete_security_group('fog_security_group')
|
||||
ec2.delete_security_group('fog_security_group')
|
||||
end
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
actual = @ec2.describe_security_groups
|
||||
actual = ec2.describe_security_groups
|
||||
actual.body['requestId'].should be_a(String)
|
||||
actual.body['securityGroupInfo'].should be_an(Array)
|
||||
security_group = actual.body['securityGroupInfo'].select do |security_group|
|
||||
|
@ -26,7 +25,7 @@ describe 'EC2.describe_security_groups' do
|
|||
end
|
||||
|
||||
it "should return proper attributes with params" do
|
||||
actual = @ec2.describe_security_groups('fog_security_group')
|
||||
actual = ec2.describe_security_groups('fog_security_group')
|
||||
actual.body['requestId'].should be_a(String)
|
||||
actual.body['securityGroupInfo'].should be_an(Array)
|
||||
security_group = actual.body['securityGroupInfo'].select do |security_group|
|
||||
|
@ -40,7 +39,7 @@ describe 'EC2.describe_security_groups' do
|
|||
|
||||
it "should raise a BadRequest error if the security group does not exist" do
|
||||
lambda {
|
||||
@ec2.describe_security_groups('not_a_security_group')
|
||||
ec2.describe_security_groups('not_a_security_group')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,21 +3,20 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.describe_snapshots' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
@snapshot_id = @ec2.create_snapshot(@volume_id).body['snapshotId']
|
||||
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
@snapshot_id = ec2.create_snapshot(@volume_id).body['snapshotId']
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.delete_volume(@volume_id)
|
||||
ec2.delete_volume(@volume_id)
|
||||
eventually do
|
||||
@ec2.delete_snapshot(@snapshot_id)
|
||||
ec2.delete_snapshot(@snapshot_id)
|
||||
end
|
||||
end
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
eventually do
|
||||
actual = @ec2.describe_snapshots
|
||||
actual = ec2.describe_snapshots
|
||||
actual.body['snapshotSet'].should be_an(Array)
|
||||
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
|
||||
snapshot['progress'].should be_a(String)
|
||||
|
@ -30,7 +29,7 @@ describe 'EC2.describe_snapshots' do
|
|||
|
||||
it "should return proper attributes with params" do
|
||||
eventually do
|
||||
actual = @ec2.describe_snapshots([@snapshot_id])
|
||||
actual = ec2.describe_snapshots([@snapshot_id])
|
||||
actual.body['snapshotSet'].should be_an(Array)
|
||||
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
|
||||
snapshot['progress'].should be_a(String)
|
||||
|
|
|
@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.describe_volumes' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.delete_volume(@volume_id)
|
||||
ec2.delete_volume(@volume_id)
|
||||
end
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
actual = @ec2.describe_volumes
|
||||
actual = ec2.describe_volumes
|
||||
actual.body['requestId'].should be_a(String)
|
||||
volume = actual.body['volumeSet'].select {|volume| volume['volumeId'] == @volume_id}.first
|
||||
volume['availabilityZone'].should be_a(String)
|
||||
|
@ -25,7 +24,7 @@ describe 'EC2.describe_volumes' do
|
|||
end
|
||||
|
||||
it "should return proper attributes for specific volume" do
|
||||
actual = @ec2.describe_volumes(@volume_id)
|
||||
actual = ec2.describe_volumes(@volume_id)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
volume = actual.body['volumeSet'].select {|volume| volume['volumeId'] == @volume_id}.first
|
||||
volume['availabilityZone'].should be_a(String)
|
||||
|
@ -39,7 +38,7 @@ describe 'EC2.describe_volumes' do
|
|||
|
||||
it "should raise a BadRequest error if volume does not exist" do
|
||||
lambda {
|
||||
@ec2.describe_volumes('vol-00000000')
|
||||
ec2.describe_volumes('vol-00000000')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,24 +3,23 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.detach_volume' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@instance_id = @ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
|
||||
@volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
|
||||
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
eventually(128) do
|
||||
@ec2.attach_volume(@volume_id, @instance_id, '/dev/sdh')
|
||||
ec2.attach_volume(@volume_id, @instance_id, '/dev/sdh')
|
||||
end
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
eventually do
|
||||
@ec2.delete_volume(@volume_id)
|
||||
@ec2.terminate_instances([@instance_id])
|
||||
ec2.delete_volume(@volume_id)
|
||||
ec2.terminate_instances([@instance_id])
|
||||
end
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
eventually do
|
||||
actual = @ec2.detach_volume(@volume_id)
|
||||
actual = ec2.detach_volume(@volume_id)
|
||||
actual.body['attachTime'].should be_a(Time)
|
||||
actual.body['device'].should be_a(String)
|
||||
actual.body['instanceId'].should be_a(String)
|
||||
|
|
|
@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.disassociate_address' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
||||
@public_ip = @ec2.allocate_address.body['publicIp']
|
||||
@ec2.associate_address(@instance_id, @public_ip)
|
||||
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
||||
@public_ip = ec2.allocate_address.body['publicIp']
|
||||
ec2.associate_address(@instance_id, @public_ip)
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.release_address(@public_ip)
|
||||
@ec2.terminate_instances([@instance_id])
|
||||
ec2.release_address(@public_ip)
|
||||
ec2.terminate_instances([@instance_id])
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.disassociate_address(@public_ip)
|
||||
actual = ec2.disassociate_address(@public_ip)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
[false, true].should include(actual.body['return'])
|
||||
end
|
||||
|
|
|
@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.get_console_output' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
||||
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.terminate_instances([@instance_id])
|
||||
ec2.terminate_instances([@instance_id])
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.get_console_output(@instance_id)
|
||||
actual = ec2.get_console_output(@instance_id)
|
||||
actual.body['instanceId'].should be_a(String)
|
||||
actual.body['output'].should be_a(String)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
|
|
|
@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.reboot_instances' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
||||
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.terminate_instances([@instance_id])
|
||||
ec2.terminate_instances([@instance_id])
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.reboot_instances([@instance_id])
|
||||
actual = ec2.reboot_instances([@instance_id])
|
||||
actual.body['requestId'].should be_a(String)
|
||||
[false, true].should include(actual.body['return'])
|
||||
end
|
||||
|
|
|
@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.release_address' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@public_ip = @ec2.allocate_address.body['publicIp']
|
||||
@public_ip = ec2.allocate_address.body['publicIp']
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.release_address(@public_ip)
|
||||
actual = ec2.release_address(@public_ip)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
actual.body['return'].should == true
|
||||
end
|
||||
|
||||
it "should raise a BadRequest error if address does not exist" do
|
||||
lambda {
|
||||
@ec2.release_address('127.0.0.1')
|
||||
ec2.release_address('127.0.0.1')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,9 +3,8 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.revoke_security_group_ingress' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
||||
@ec2.authorize_security_group_ingress({
|
||||
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
||||
ec2.authorize_security_group_ingress({
|
||||
'FromPort' => 80,
|
||||
'GroupName' => 'fog_security_group',
|
||||
'IpProtocol' => 'tcp',
|
||||
|
@ -14,11 +13,11 @@ describe 'EC2.revoke_security_group_ingress' do
|
|||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.delete_security_group('fog_security_group')
|
||||
ec2.delete_security_group('fog_security_group')
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.revoke_security_group_ingress({
|
||||
actual = ec2.revoke_security_group_ingress({
|
||||
'FromPort' => 80,
|
||||
'GroupName' => 'fog_security_group',
|
||||
'IpProtocol' => 'tcp',
|
||||
|
|
|
@ -2,16 +2,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
|
||||
describe 'EC2.run_instances' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@ec2.terminate_instances([@instance_id])
|
||||
ec2.terminate_instances([@instance_id])
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.run_instances('ami-5ee70037', 1, 1)
|
||||
actual = ec2.run_instances('ami-5ee70037', 1, 1)
|
||||
@instance_id = actual.body['instancesSet'].first['instanceId']
|
||||
actual.body['groupSet'].should be_an(Array)
|
||||
actual.body['groupSet'].first.should be_a(String)
|
||||
|
|
|
@ -3,12 +3,11 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.terminate_instances' do
|
||||
|
||||
before(:all) do
|
||||
@ec2 = Fog::AWS::EC2.gen
|
||||
@instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
||||
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = @ec2.terminate_instances([@instance_id])
|
||||
actual = ec2.terminate_instances([@instance_id])
|
||||
actual.body['requestId'].should be_a(String)
|
||||
actual.body['instancesSet'].should be_an(Array)
|
||||
instance = actual.body['instancesSet'].select {|instance| instance['instanceId'] == @instance_id}.first
|
||||
|
|
|
@ -3,22 +3,21 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'S3.copy_object' do
|
||||
|
||||
before(:all) do
|
||||
@s3 = Fog::AWS::S3.gen
|
||||
@s3.put_bucket('fogcopyobjectsource')
|
||||
s3.put_bucket('fogcopyobjectsource')
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
@s3.put_object('fogcopyobjectsource', 'fog_copy_object_source', file)
|
||||
@s3.put_bucket('fogcopyobjectdestination')
|
||||
s3.put_object('fogcopyobjectsource', 'fog_copy_object_source', file)
|
||||
s3.put_bucket('fogcopyobjectdestination')
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@s3.delete_object('fogcopyobjectdestination', 'fog_copy_object_destination')
|
||||
@s3.delete_bucket('fogcopyobjectdestination')
|
||||
@s3.delete_object('fogcopyobjectsource', 'fog_copy_object_source')
|
||||
@s3.delete_bucket('fogcopyobjectsource')
|
||||
s3.delete_object('fogcopyobjectdestination', 'fog_copy_object_destination')
|
||||
s3.delete_bucket('fogcopyobjectdestination')
|
||||
s3.delete_object('fogcopyobjectsource', 'fog_copy_object_source')
|
||||
s3.delete_bucket('fogcopyobjectsource')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = @s3.copy_object(
|
||||
actual = s3.copy_object(
|
||||
'fogcopyobjectsource', 'fog_copy_object_source',
|
||||
'fogcopyobjectdestination', 'fog_copy_object_destination'
|
||||
)
|
||||
|
@ -29,7 +28,7 @@ describe 'S3.copy_object' do
|
|||
|
||||
it 'should raise a NotFound error if the source_bucket does not exist' do
|
||||
lambda {
|
||||
@s3.copy_object(
|
||||
s3.copy_object(
|
||||
'fognotabucket', 'fog_copy_object_source',
|
||||
'fogcopyobjectdestination', 'fog_copy_object_destination'
|
||||
)
|
||||
|
@ -38,7 +37,7 @@ describe 'S3.copy_object' do
|
|||
|
||||
it 'should raise a NotFound error if the source_object does not exist' do
|
||||
lambda {
|
||||
@s3.copy_object(
|
||||
s3.copy_object(
|
||||
'fogcopyobjectsource', 'fog_not_an_object',
|
||||
'fogcopyobjectdestination', 'fog_copy_object_destination'
|
||||
)
|
||||
|
@ -47,7 +46,7 @@ describe 'S3.copy_object' do
|
|||
|
||||
it 'should raise a NotFound error if the target_bucket does not exist' do
|
||||
lambda {
|
||||
@s3.copy_object(
|
||||
s3.copy_object(
|
||||
'fogcopyobjectsource', 'fog_copy_object_source',
|
||||
'fognotabucket', 'fog_copy_object_destination'
|
||||
)
|
||||
|
|
|
@ -3,18 +3,17 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'S3.delete_bucket' do
|
||||
|
||||
before(:all) do
|
||||
@s3 = Fog::AWS::S3.gen
|
||||
@s3.put_bucket('fogdeletebucket')
|
||||
s3.put_bucket('fogdeletebucket')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = @s3.delete_bucket('fogdeletebucket')
|
||||
actual = s3.delete_bucket('fogdeletebucket')
|
||||
actual.status.should == 204
|
||||
end
|
||||
|
||||
it 'should raise a NotFound error if the bucket does not exist' do
|
||||
lambda {
|
||||
@s3.delete_bucket('fognotabucket')
|
||||
s3.delete_bucket('fognotabucket')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,29 +3,28 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'S3.delete_object' do
|
||||
|
||||
before(:all) do
|
||||
@s3 = Fog::AWS::S3.gen
|
||||
@s3.put_bucket('fogdeleteobject')
|
||||
s3.put_bucket('fogdeleteobject')
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
@s3.put_object('fogdeleteobject', 'fog_delete_object', file)
|
||||
s3.put_object('fogdeleteobject', 'fog_delete_object', file)
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@s3.delete_bucket('fogdeleteobject')
|
||||
s3.delete_bucket('fogdeleteobject')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = @s3.delete_object('fogdeleteobject', 'fog_delete_object')
|
||||
actual = s3.delete_object('fogdeleteobject', 'fog_delete_object')
|
||||
actual.status.should == 204
|
||||
end
|
||||
|
||||
it 'should raise NotFound error if the bucket does not exist' do
|
||||
lambda {
|
||||
@s3.delete_object('fognotabucket', 'fog_delete_object')
|
||||
s3.delete_object('fognotabucket', 'fog_delete_object')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
end
|
||||
|
||||
it 'should not raise an error if the object does not exist' do
|
||||
@s3.delete_object('fogdeleteobject', 'fog_not_an_object')
|
||||
s3.delete_object('fogdeleteobject', 'fog_not_an_object')
|
||||
end
|
||||
|
||||
end
|
|
@ -3,27 +3,22 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'S3.get_bucket_location' do
|
||||
|
||||
before(:all) do
|
||||
@s3 = Fog::AWS::S3.gen
|
||||
@eu_s3 = Fog::AWS::S3.gen(:eu)
|
||||
@s3.put_bucket('foggetlocation', 'LocationConstraint' => 'EU')
|
||||
s3.put_bucket('foggetlocation', 'LocationConstraint' => 'EU')
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
if Fog.mocking?
|
||||
@eu_s3.data = @s3.data
|
||||
end
|
||||
@eu_s3.delete_bucket('foggetlocation')
|
||||
eu_s3.delete_bucket('foggetlocation')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = @s3.get_bucket_location('foggetlocation')
|
||||
actual = s3.get_bucket_location('foggetlocation')
|
||||
actual.status.should == 200
|
||||
actual.body['LocationConstraint'].should == 'EU'
|
||||
end
|
||||
|
||||
it 'should raise NotFound error if bucket does not exist' do
|
||||
lambda {
|
||||
@s3.get_bucket_location('fognotabucket')
|
||||
s3.get_bucket_location('fognotabucket')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'S3.get_bucket' do
|
||||
|
||||
before(:all) do
|
||||
@s3 = Fog::AWS::S3.gen
|
||||
@s3.put_bucket('foggetbucket')
|
||||
s3.put_bucket('foggetbucket')
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
@s3.put_object('foggetbucket', 'fog_get_bucket', file)
|
||||
s3.put_object('foggetbucket', 'fog_get_bucket', file)
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@s3.delete_object('foggetbucket', 'fog_get_bucket')
|
||||
@s3.delete_bucket('foggetbucket')
|
||||
s3.delete_object('foggetbucket', 'fog_get_bucket')
|
||||
s3.delete_bucket('foggetbucket')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = @s3.get_bucket('foggetbucket')
|
||||
actual = s3.get_bucket('foggetbucket')
|
||||
actual.body['IsTruncated'].should == false
|
||||
actual.body['Marker'].should be_a(String)
|
||||
actual.body['MaxKeys'].should be_an(Integer)
|
||||
|
@ -34,7 +33,7 @@ describe 'S3.get_bucket' do
|
|||
end
|
||||
|
||||
it 'should accept options' do
|
||||
actual = @s3.get_bucket('foggetbucket', 'prefix' => 'fog_')
|
||||
actual = s3.get_bucket('foggetbucket', 'prefix' => 'fog_')
|
||||
actual.body['IsTruncated'].should == false
|
||||
actual.body['Marker'].should be_a(String)
|
||||
actual.body['MaxKeys'].should be_an(Integer)
|
||||
|
@ -54,7 +53,7 @@ describe 'S3.get_bucket' do
|
|||
|
||||
it 'should raise a NotFound error if the bucket does not exist' do
|
||||
lambda {
|
||||
@s3.get_bucket('fognotabucket')
|
||||
s3.get_bucket('fognotabucket')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'S3.get_object' do
|
||||
|
||||
before(:all) do
|
||||
@s3 = Fog::AWS::S3.gen
|
||||
@s3.put_bucket('foggetobject')
|
||||
s3.put_bucket('foggetobject')
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
@s3.put_object('foggetobject', 'fog_get_object', file)
|
||||
s3.put_object('foggetobject', 'fog_get_object', file)
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@s3.delete_object('foggetobject', 'fog_get_object')
|
||||
@s3.delete_bucket('foggetobject')
|
||||
s3.delete_object('foggetobject', 'fog_get_object')
|
||||
s3.delete_bucket('foggetobject')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = @s3.get_object('foggetobject', 'fog_get_object')
|
||||
actual = s3.get_object('foggetobject', 'fog_get_object')
|
||||
actual.status.should == 200
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
data = file.read
|
||||
|
@ -27,13 +26,13 @@ describe 'S3.get_object' do
|
|||
|
||||
it 'should raise a NotFound error if the bucket does not exist' do
|
||||
lambda {
|
||||
@s3.get_object('fognotabucket', 'fog_get_object')
|
||||
s3.get_object('fognotabucket', 'fog_get_object')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
end
|
||||
|
||||
it 'should raise a NotFound error if the object does not exist' do
|
||||
lambda {
|
||||
@s3.get_object('foggetobject', 'fog_not_an_object')
|
||||
s3.get_object('foggetobject', 'fog_not_an_object')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,23 +3,22 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'S3.get_request_payment' do
|
||||
|
||||
before(:all) do
|
||||
@s3 = Fog::AWS::S3.gen
|
||||
@s3.put_bucket('foggetrequestpayment')
|
||||
s3.put_bucket('foggetrequestpayment')
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@s3.delete_bucket('foggetrequestpayment')
|
||||
s3.delete_bucket('foggetrequestpayment')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = @s3.get_request_payment('foggetrequestpayment')
|
||||
actual = s3.get_request_payment('foggetrequestpayment')
|
||||
actual.status.should == 200
|
||||
actual.body['Payer'].should == 'BucketOwner'
|
||||
end
|
||||
|
||||
it 'should raise a NotFound error if the bucket does not exist' do
|
||||
lambda {
|
||||
@s3.get_request_payment('fognotabucket')
|
||||
s3.get_request_payment('fognotabucket')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'S3.get_service' do
|
||||
|
||||
before(:all) do
|
||||
@s3 = Fog::AWS::S3.gen
|
||||
@s3.put_bucket('foggetservice')
|
||||
s3.put_bucket('foggetservice')
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@s3.delete_bucket('foggetservice')
|
||||
s3.delete_bucket('foggetservice')
|
||||
end
|
||||
|
||||
it 'should return proper_attributes' do
|
||||
actual = @s3.get_service
|
||||
actual = s3.get_service
|
||||
actual.body['Buckets'].should be_an(Array)
|
||||
bucket = actual.body['Buckets'].select {|bucket| bucket['Name'] == 'foggetservice'}.first
|
||||
bucket['CreationDate'].should be_a(Time)
|
||||
|
@ -24,7 +23,7 @@ describe 'S3.get_service' do
|
|||
|
||||
it 'should include foggetservice in get_service' do
|
||||
eventually do
|
||||
actual = @s3.get_service
|
||||
actual = s3.get_service
|
||||
actual.body['Buckets'].collect { |bucket| bucket['Name'] }.should include('foggetservice')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'S3.head_object' do
|
||||
|
||||
before(:all) do
|
||||
@s3 = Fog::AWS::S3.gen
|
||||
@s3.put_bucket('fogheadobject')
|
||||
s3.put_bucket('fogheadobject')
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
@s3.put_object('fogheadobject', 'fog_head_object', file)
|
||||
s3.put_object('fogheadobject', 'fog_head_object', file)
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@s3.delete_object('fogheadobject', 'fog_head_object')
|
||||
@s3.delete_bucket('fogheadobject')
|
||||
s3.delete_object('fogheadobject', 'fog_head_object')
|
||||
s3.delete_bucket('fogheadobject')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = @s3.head_object('fogheadobject', 'fog_head_object')
|
||||
actual = s3.head_object('fogheadobject', 'fog_head_object')
|
||||
actual.status.should == 200
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
data = file.read
|
||||
|
|
|
@ -2,21 +2,17 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
|
||||
describe 'S3.put_bucket' do
|
||||
|
||||
before(:all) do
|
||||
@s3 = Fog::AWS::S3.gen
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@s3.delete_bucket('fogputbucket')
|
||||
s3.delete_bucket('fogputbucket')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = @s3.put_bucket('fogputbucket')
|
||||
actual = s3.put_bucket('fogputbucket')
|
||||
actual.status.should == 200
|
||||
end
|
||||
|
||||
it 'should not raise an error if the bucket already exists' do
|
||||
@s3.put_bucket('fogputbucket')
|
||||
s3.put_bucket('fogputbucket')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -3,31 +3,30 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'S3.put_object' do
|
||||
|
||||
before(:all) do
|
||||
@s3 = Fog::AWS::S3.gen
|
||||
@s3.put_bucket('fogputobject')
|
||||
s3.put_bucket('fogputobject')
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@s3.delete_object('fogputobject', 'fog_put_object')
|
||||
@s3.delete_bucket('fogputobject')
|
||||
s3.delete_object('fogputobject', 'fog_put_object')
|
||||
s3.delete_bucket('fogputobject')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
actual = @s3.put_object('fogputobject', 'fog_put_object', file)
|
||||
actual = s3.put_object('fogputobject', 'fog_put_object', file)
|
||||
actual.status.should == 200
|
||||
end
|
||||
|
||||
it 'should raise a NotFound error if the bucket does not exist' do
|
||||
lambda {
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
@s3.put_object('fognotabucket', 'fog_put_object', file)
|
||||
s3.put_object('fognotabucket', 'fog_put_object', file)
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
end
|
||||
|
||||
it 'should not raise an error if the object already exists' do
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
actual = @s3.put_object('fogputobject', 'fog_put_object', file)
|
||||
actual = s3.put_object('fogputobject', 'fog_put_object', file)
|
||||
actual.status.should == 200
|
||||
end
|
||||
|
||||
|
|
|
@ -3,22 +3,21 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'S3.put_request_payment' do
|
||||
|
||||
before(:all) do
|
||||
@s3 = Fog::AWS::S3.gen
|
||||
@s3.put_bucket('fogputrequestpayment')
|
||||
s3.put_bucket('fogputrequestpayment')
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@s3.delete_bucket('fogputrequestpayment')
|
||||
s3.delete_bucket('fogputrequestpayment')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = @s3.put_request_payment('fogputrequestpayment', 'Requester')
|
||||
actual = s3.put_request_payment('fogputrequestpayment', 'Requester')
|
||||
actual.status.should == 200
|
||||
end
|
||||
|
||||
it 'should raise a NotFound error if bucket does not exist' do
|
||||
lambda {
|
||||
@s3.put_request_payment('fognotabucket', 'Requester')
|
||||
s3.put_request_payment('fognotabucket', 'Requester')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,17 +3,16 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'SimpleDB.batch_put_attributes' do
|
||||
|
||||
before(:all) do
|
||||
@sdb = Fog::AWS::SimpleDB.gen
|
||||
@domain_name = "fog_domain_#{Time.now.to_i}"
|
||||
@sdb.create_domain(@domain_name)
|
||||
sdb.create_domain(@domain_name)
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@sdb.delete_domain(@domain_name)
|
||||
sdb.delete_domain(@domain_name)
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = @sdb.batch_put_attributes(@domain_name, { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } })
|
||||
actual = sdb.batch_put_attributes(@domain_name, { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } })
|
||||
actual.body['RequestId'].should be_a(String)
|
||||
actual.body['BoxUsage'].should be_a(Float)
|
||||
end
|
||||
|
|
|
@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'SimpleDB.create_domain' do
|
||||
|
||||
before(:all) do
|
||||
@sdb = Fog::AWS::SimpleDB.gen
|
||||
@domain_name = "fog_domain_#{Time.now.to_i}"
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@sdb.delete_domain(@domain_name)
|
||||
sdb.delete_domain(@domain_name)
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = @sdb.create_domain(@domain_name)
|
||||
actual = sdb.create_domain(@domain_name)
|
||||
actual.body['RequestId'].should be_a(String)
|
||||
actual.body['BoxUsage'].should be_a(Float)
|
||||
end
|
||||
|
|
|
@ -3,17 +3,16 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'SimpleDB.delete_attributes' do
|
||||
|
||||
before(:all) do
|
||||
@sdb = Fog::AWS::SimpleDB.gen
|
||||
@sdb.create_domain('delete_attributes')
|
||||
@sdb.put_attributes('delete_attributes', 'foo', { :bar => :baz })
|
||||
sdb.create_domain('delete_attributes')
|
||||
sdb.put_attributes('delete_attributes', 'foo', { :bar => :baz })
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@sdb.delete_domain('delete_attributes')
|
||||
sdb.delete_domain('delete_attributes')
|
||||
end
|
||||
|
||||
it 'should return proper attributes from delete_attributes' do
|
||||
actual = @sdb.delete_attributes('delete_attributes', 'foo')
|
||||
actual = sdb.delete_attributes('delete_attributes', 'foo')
|
||||
actual.body['RequestId'].should be_a(String)
|
||||
actual.body['BoxUsage'].should be_a(Float)
|
||||
end
|
||||
|
|
|
@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'SimpleDB.delete_domain' do
|
||||
|
||||
before(:all) do
|
||||
@sdb = Fog::AWS::SimpleDB.gen
|
||||
@domain_name = "fog_domain_#{Time.now.to_i}"
|
||||
end
|
||||
|
||||
before(:all) do
|
||||
@sdb.create_domain(@domain_name)
|
||||
sdb.create_domain(@domain_name)
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = @sdb.delete_domain(@domain_name)
|
||||
actual = sdb.delete_domain(@domain_name)
|
||||
actual.body['RequestId'].should be_a(String)
|
||||
actual.body['BoxUsage'].should be_a(Float)
|
||||
end
|
||||
|
|
|
@ -3,17 +3,16 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'SimpleDB.domain_metadata' do
|
||||
|
||||
before(:all) do
|
||||
@sdb = Fog::AWS::SimpleDB.gen
|
||||
@domain_name = "fog_domain_#{Time.now.to_i}"
|
||||
@sdb.create_domain(@domain_name)
|
||||
sdb.create_domain(@domain_name)
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@sdb.delete_domain(@domain_name)
|
||||
sdb.delete_domain(@domain_name)
|
||||
end
|
||||
|
||||
it 'should return proper attributes when there are no items' do
|
||||
results = @sdb.domain_metadata(@domain_name)
|
||||
results = sdb.domain_metadata(@domain_name)
|
||||
results.body['AttributeNameCount'].should == 0
|
||||
results.body['AttributeNamesSizeBytes'].should == 0
|
||||
results.body['AttributeValueCount'].should == 0
|
||||
|
@ -26,8 +25,8 @@ describe 'SimpleDB.domain_metadata' do
|
|||
end
|
||||
|
||||
it 'should return proper attributes with items' do
|
||||
@sdb.put_attributes(@domain_name, 'foo', { :bar => :baz })
|
||||
results = @sdb.domain_metadata(@domain_name)
|
||||
sdb.put_attributes(@domain_name, 'foo', { :bar => :baz })
|
||||
results = sdb.domain_metadata(@domain_name)
|
||||
results.body['AttributeNameCount'].should == 1
|
||||
results.body['AttributeNamesSizeBytes'].should == 3
|
||||
results.body['AttributeValueCount'].should == 1
|
||||
|
|
|
@ -3,26 +3,25 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'SimpleDB.get_attributes' do
|
||||
|
||||
before(:all) do
|
||||
@sdb = Fog::AWS::SimpleDB.gen
|
||||
@domain_name = "fog_domain_#{Time.now.to_i}"
|
||||
@sdb.create_domain(@domain_name)
|
||||
sdb.create_domain(@domain_name)
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@sdb.delete_domain(@domain_name)
|
||||
sdb.delete_domain(@domain_name)
|
||||
end
|
||||
|
||||
it 'should have no attributes for foo before put_attributes' do
|
||||
eventually do
|
||||
actual = @sdb.get_attributes(@domain_name, 'foo')
|
||||
actual = sdb.get_attributes(@domain_name, 'foo')
|
||||
actual.body['Attributes'].should be_empty
|
||||
end
|
||||
end
|
||||
|
||||
it 'should have attributes for foo after put_attributes' do
|
||||
@sdb.put_attributes(@domain_name, 'foo', { :bar => :baz })
|
||||
sdb.put_attributes(@domain_name, 'foo', { :bar => :baz })
|
||||
eventually do
|
||||
actual = @sdb.get_attributes(@domain_name, 'foo')
|
||||
actual = sdb.get_attributes(@domain_name, 'foo')
|
||||
actual.body['Attributes'].should == { 'bar' => ['baz'] }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,25 +3,24 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'SimpleDB.list_domains' do
|
||||
|
||||
before(:all) do
|
||||
@sdb = Fog::AWS::SimpleDB.gen
|
||||
@domain_name = "fog_domain_#{Time.now.to_i}"
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@sdb.delete_domain(@domain_name)
|
||||
sdb.delete_domain(@domain_name)
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
results = @sdb.list_domains
|
||||
results = sdb.list_domains
|
||||
results.body['BoxUsage'].should be_a(Float)
|
||||
results.body['Domains'].should be_an(Array)
|
||||
results.body['RequestId'].should be_a(String)
|
||||
end
|
||||
|
||||
it 'should include created domains' do
|
||||
@sdb.create_domain(@domain_name)
|
||||
sdb.create_domain(@domain_name)
|
||||
eventually do
|
||||
actual = @sdb.list_domains
|
||||
actual = sdb.list_domains
|
||||
actual.body['Domains'].should include(@domain_name)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,17 +3,16 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'SimpleDB.put_attributes' do
|
||||
|
||||
before(:all) do
|
||||
@sdb = Fog::AWS::SimpleDB.gen
|
||||
@domain_name = "fog_domain_#{Time.now.to_i}"
|
||||
@sdb.create_domain(@domain_name)
|
||||
sdb.create_domain(@domain_name)
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@sdb.delete_domain(@domain_name)
|
||||
sdb.delete_domain(@domain_name)
|
||||
end
|
||||
|
||||
it 'should return proper attributes from put_attributes' do
|
||||
actual = @sdb.put_attributes(@domain_name, 'foo', { 'bar' => 'baz' })
|
||||
actual = sdb.put_attributes(@domain_name, 'foo', { 'bar' => 'baz' })
|
||||
actual.body['RequestId'].should be_a(String)
|
||||
actual.body['BoxUsage'].should be_a(Float)
|
||||
end
|
||||
|
|
|
@ -12,41 +12,33 @@ def credentials
|
|||
end
|
||||
end
|
||||
|
||||
module Fog
|
||||
module AWS
|
||||
def ec2
|
||||
Fog::AWS::EC2.new(
|
||||
:aws_access_key_id => credentials['aws_access_key_id'],
|
||||
:aws_secret_access_key => credentials['aws_secret_access_key']
|
||||
)
|
||||
end
|
||||
|
||||
class EC2
|
||||
def self.gen
|
||||
new(
|
||||
:aws_access_key_id => credentials['aws_access_key_id'],
|
||||
:aws_secret_access_key => credentials['aws_secret_access_key']
|
||||
)
|
||||
end
|
||||
end
|
||||
def eu_s3
|
||||
Fog::AWS::S3.new(
|
||||
:aws_access_key_id => credentials['aws_access_key_id'],
|
||||
:aws_secret_access_key => credentials['aws_secret_access_key'],
|
||||
:host => 's3-external-3.amazonaws.com'
|
||||
)
|
||||
end
|
||||
|
||||
class S3
|
||||
def self.gen(location = nil)
|
||||
if location == :eu
|
||||
host = 's3-external-3.amazonaws.com'
|
||||
end
|
||||
new(
|
||||
:aws_access_key_id => credentials['aws_access_key_id'],
|
||||
:aws_secret_access_key => credentials['aws_secret_access_key'],
|
||||
:host => host
|
||||
)
|
||||
end
|
||||
end
|
||||
def sdb
|
||||
Fog::AWS::SimpleDB.new(
|
||||
:aws_access_key_id => credentials['aws_access_key_id'],
|
||||
:aws_secret_access_key => credentials['aws_secret_access_key']
|
||||
)
|
||||
end
|
||||
|
||||
class SimpleDB
|
||||
def self.gen
|
||||
new(
|
||||
:aws_access_key_id => credentials['aws_access_key_id'],
|
||||
:aws_secret_access_key => credentials['aws_secret_access_key']
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
def s3
|
||||
Fog::AWS::S3.new(
|
||||
:aws_access_key_id => credentials['aws_access_key_id'],
|
||||
:aws_secret_access_key => credentials['aws_secret_access_key']
|
||||
)
|
||||
end
|
||||
|
||||
def eventually(max_delay = 16, &block)
|
||||
|
|
Loading…
Reference in a new issue