Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
195 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# A sample Guardfile | ||
# More info at https://github.com/guard/guard#readme | ||
|
||
guard 'rspec', version: 2, cli: '-c -f doc' do | ||
watch(%r{^spec/.+_spec\.rb$}) | ||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } | ||
watch('spec/spec_helper.rb') { "spec" } | ||
watch(%r{^spec/support/(.+)\.rb$}) { "spec" } | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,46 @@ | ||
require "bundler/gem_tasks" | ||
$:.unshift File.join(File.dirname(__FILE__), 'lib') | ||
require 'em-aws' | ||
|
||
|
||
namespace :clean do | ||
EM::AWS.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID'] | ||
EM::AWS.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY'] | ||
|
||
desc "Deletes any leftover SQS queues (EM-AWS-Test-Queue-*)" | ||
task :queues do | ||
EM.run do | ||
q = EM::Queue.new | ||
sqs = EM::AWS::SQS.new | ||
puts "Retrieving test queues..." | ||
list = sqs.list_queues(queue_name_prefix: 'EM-AWS-Test-Queue') | ||
list.callback {|r| q.push *Array(r[:queue_url])} | ||
list.errback do |r| | ||
puts "ERROR: #{r.error}" | ||
EM.stop | ||
end | ||
|
||
EM.add_periodic_timer(0.1) do | ||
q.pop do |url| | ||
puts "Deleting #{url}..." | ||
queue = EM::AWS::SQS.new url: url | ||
del = queue.delete_queue | ||
del.callback {|r| puts " --Deleted #{url}"} | ||
del.errback do |r| | ||
puts " **ERROR: #{r.error} on #{url}" | ||
q.push url | ||
end | ||
end | ||
end | ||
|
||
EM.add_periodic_timer(5) do | ||
if q.empty? | ||
puts "All queues deleted." | ||
EM.stop | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,53 @@ | ||
require_relative '../spec_helper' | ||
|
||
describe EventMachine::AWS::SQS, :live do | ||
subject {EM::AWS::SQS.new} | ||
describe EventMachine::AWS::SQS do | ||
|
||
before(:all) do | ||
queue_name = "EM-AWS-Test-Queue-#{Time.now.to_i}" | ||
create_response = subject.create_queue(queue_name: queue_name) | ||
create_response.should be_success | ||
@queue = create_response.queue_url | ||
@queue_name = "EM-AWS-Test-Queue-#{Time.now.to_i}" | ||
end | ||
|
||
it_behaves_like "an AWS Query" | ||
|
||
it "can create a queue" do | ||
@topic.should =~ /^arn:aws:sns:.*#{@test_topic}$/ | ||
end | ||
it_behaves_like "an AWS Query" | ||
|
||
it "can retrieve a list of queues" do | ||
response = subject.list_queues | ||
response.queues.should include({queue_url: @topic}) | ||
it "derives the queue name from the URL" do | ||
this = EM::AWS::SQS::new url: 'http://dummy.amazonaws.com/fake-queue-name' | ||
this.queue_name.should == 'fake-queue-name' | ||
end | ||
|
||
after(:all) do | ||
delete_response = subject.delete_queue(topic_arn: @topic) | ||
delete_response.should be_success | ||
|
||
context "operations", :live do | ||
before(:all) do | ||
@queue = EM::AWS::SQS.create @queue_name | ||
sleep 60 | ||
end | ||
|
||
subject { @queue } | ||
|
||
it "points to the proper queue" do | ||
subject.url.should =~ /http.*\/#{@queue_name}$/ | ||
end | ||
|
||
it "can retrieve a list of queues" do | ||
response = subject.list_queues | ||
response.queue_url.should include(subject.url) | ||
end | ||
|
||
it "can get the queue by name" do | ||
queue = EM::AWS::SQS.get @queue_name | ||
queue.url.should == subject.url | ||
end | ||
|
||
it "can set attributes on the queue" do | ||
subject.set_queue_attributes attribute: {maximum_message_size: 1024} | ||
sleep 10 | ||
response = subject.get_queue_attributes attribute_name: [:maximum_message_size] | ||
response.attribute[:maximum_message_size].should == 1024 | ||
end | ||
|
||
|
||
after(:all) do | ||
sleep 10 | ||
delete_response = subject.delete_queue | ||
delete_response.should be_success | ||
end | ||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.