fake_sqs 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/bin/fake_sqs +2 -0
- data/lib/fake_sqs/actions/get_queue_attributes.rb +25 -0
- data/lib/fake_sqs/actions/set_queue_attributes.rb +25 -0
- data/lib/fake_sqs/api.rb +2 -0
- data/lib/fake_sqs/queue.rb +4 -2
- data/lib/fake_sqs/version.rb +1 -1
- data/spec/acceptance/queue_actions_spec.rb +17 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 909e1da7c44403638eb5d95fe363a7d2c7282135
|
4
|
+
data.tar.gz: 94f87e79eef035cf8c6d89f0de61d1cd4e5f951c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ace909c2bcf251ea0234b0ceb5804bf5b5780765d41ea838bff230a7a8765caa0a32b6792eace91783b8a0a73022d93bf5e5d815236e9ec1a8e8aa1f236014f
|
7
|
+
data.tar.gz: 2e7baaa00ba1fe6da88e20276edad298813f7477c3be0fb82bc0c988e6ddfab7cd33ff211c058677da08b53633369b80b0ef6de3382a7bed7463d78d0af85b43
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ testing, just like you would have a local database running. Fake SQS doesn't
|
|
6
6
|
persist anything, not even the queues themselves. You'll have to create the
|
7
7
|
queues everytime you start it.
|
8
8
|
|
9
|
-
This implementation is **not complete** yet.
|
9
|
+
This implementation is **not complete** yet, but should be useful already.
|
10
10
|
|
11
11
|
Done so far are:
|
12
12
|
|
@@ -17,6 +17,7 @@ Done so far are:
|
|
17
17
|
* Send messages (and in batch)
|
18
18
|
* Receive messages (and in batch)
|
19
19
|
* Deleting messages (and in batch)
|
20
|
+
* Changing queue attributes (but not all, and no validation)
|
20
21
|
|
21
22
|
Certain bits are left off on purpose, to make it easier to work with, such as:
|
22
23
|
|
@@ -27,12 +28,13 @@ Certain bits are left off on purpose, to make it easier to work with, such as:
|
|
27
28
|
Other parts are just not done yet:
|
28
29
|
|
29
30
|
* Permissions
|
30
|
-
* Changing queue attributes
|
31
31
|
* Changing message visibility
|
32
32
|
* Error handling
|
33
33
|
|
34
34
|
So, actually, just the basics are implemented at this point.
|
35
35
|
|
36
|
+
PS. There is also [Fake SNS] [fake_sns].
|
37
|
+
|
36
38
|
## Usage
|
37
39
|
|
38
40
|
To install:
|
@@ -147,3 +149,4 @@ end
|
|
147
149
|
|
148
150
|
[fake_dynamo]: https://github.com/ananthakumaran/fake_dynamo
|
149
151
|
[aws-sdk]: https://github.com/amazonwebservices/aws-sdk-for-ruby
|
152
|
+
[fake_sns]: https://github.com/yourkarma/fake_sns
|
data/bin/fake_sqs
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module FakeSQS
|
2
|
+
module Actions
|
3
|
+
class GetQueueAttributes
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
@server = options.fetch(:server)
|
7
|
+
@queues = options.fetch(:queues)
|
8
|
+
@responder = options.fetch(:responder)
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(queue_name, params)
|
12
|
+
queue = @queues.get(queue_name)
|
13
|
+
@responder.call :GetQueueAttributes do |xml|
|
14
|
+
queue.attributes.each do |name, value|
|
15
|
+
xml.Attribute do
|
16
|
+
xml.Name name
|
17
|
+
xml.Value value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module FakeSQS
|
2
|
+
module Actions
|
3
|
+
class SetQueueAttributes
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
@server = options.fetch(:server)
|
7
|
+
@queues = options.fetch(:queues)
|
8
|
+
@responder = options.fetch(:responder)
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(queue_name, params)
|
12
|
+
queue = @queues.get(queue_name)
|
13
|
+
results = {}
|
14
|
+
params.each do |key, value|
|
15
|
+
if key =~ /\AAttribute\.(\d+)\.Name\z/
|
16
|
+
results[value] = params.fetch("Attribute.#{$1}.Value")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
queue.attributes.merge!(results)
|
20
|
+
@responder.call :SetQueueAttributes
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/fake_sqs/api.rb
CHANGED
@@ -7,6 +7,8 @@ require 'fake_sqs/actions/receive_message'
|
|
7
7
|
require 'fake_sqs/actions/delete_message'
|
8
8
|
require 'fake_sqs/actions/delete_message_batch'
|
9
9
|
require 'fake_sqs/actions/send_message_batch'
|
10
|
+
require 'fake_sqs/actions/get_queue_attributes'
|
11
|
+
require 'fake_sqs/actions/set_queue_attributes'
|
10
12
|
|
11
13
|
module FakeSQS
|
12
14
|
|
data/lib/fake_sqs/queue.rb
CHANGED
@@ -6,11 +6,13 @@ module FakeSQS
|
|
6
6
|
|
7
7
|
class Queue
|
8
8
|
|
9
|
-
attr_reader :name, :messages, :message_factory, :messages_in_flight
|
9
|
+
attr_reader :name, :messages, :message_factory, :messages_in_flight, :attributes
|
10
10
|
|
11
11
|
def initialize(options = {})
|
12
12
|
@name = options.fetch("QueueName")
|
13
13
|
@message_factory = options.fetch(:message_factory)
|
14
|
+
@attributes = {}
|
15
|
+
@attributes["QueueArn"] = "arn:aws:sqs:us-east-1:#{SecureRandom.hex}:#{@name}"
|
14
16
|
reset
|
15
17
|
end
|
16
18
|
|
@@ -42,7 +44,7 @@ module FakeSQS
|
|
42
44
|
end
|
43
45
|
|
44
46
|
def delete_message(receipt)
|
45
|
-
|
47
|
+
messages_in_flight.delete(receipt)
|
46
48
|
end
|
47
49
|
|
48
50
|
def reset
|
data/lib/fake_sqs/version.rb
CHANGED
@@ -7,6 +7,7 @@ describe "Actions for Queues", :sqs do
|
|
7
7
|
specify "CreateQueue" do
|
8
8
|
queue = sqs.queues.create("test-create-queue")
|
9
9
|
queue.url.should eq "http://0.0.0.0:4568/test-create-queue"
|
10
|
+
queue.arn.should match %r"arn:aws:sqs:us-east-1:.+:test-create-queue"
|
10
11
|
end
|
11
12
|
|
12
13
|
specify "GetQueueUrl" do
|
@@ -41,4 +42,20 @@ describe "Actions for Queues", :sqs do
|
|
41
42
|
sqs.should have(0).queues
|
42
43
|
end
|
43
44
|
|
45
|
+
specify "SetQueueAttributes / GetQueueAttributes" do
|
46
|
+
|
47
|
+
policy = AWS::SQS::Policy.new
|
48
|
+
policy.allow(
|
49
|
+
:actions => ['s3:PutObject'],
|
50
|
+
:resources => "arn:aws:s3:::mybucket/mykey/*",
|
51
|
+
:principals => :any
|
52
|
+
).where(:acl).is("public-read")
|
53
|
+
|
54
|
+
queue = sqs.queues.create("my-queue")
|
55
|
+
queue.policy = policy
|
56
|
+
|
57
|
+
reloaded_queue = sqs.queues.named("my-queue")
|
58
|
+
reloaded_queue.policy.should eq policy
|
59
|
+
end
|
60
|
+
|
44
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake_sqs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -158,11 +158,13 @@ files:
|
|
158
158
|
- lib/fake_sqs/actions/delete_message.rb
|
159
159
|
- lib/fake_sqs/actions/delete_message_batch.rb
|
160
160
|
- lib/fake_sqs/actions/delete_queue.rb
|
161
|
+
- lib/fake_sqs/actions/get_queue_attributes.rb
|
161
162
|
- lib/fake_sqs/actions/get_queue_url.rb
|
162
163
|
- lib/fake_sqs/actions/list_queues.rb
|
163
164
|
- lib/fake_sqs/actions/receive_message.rb
|
164
165
|
- lib/fake_sqs/actions/send_message.rb
|
165
166
|
- lib/fake_sqs/actions/send_message_batch.rb
|
167
|
+
- lib/fake_sqs/actions/set_queue_attributes.rb
|
166
168
|
- lib/fake_sqs/api.rb
|
167
169
|
- lib/fake_sqs/catch_errors.rb
|
168
170
|
- lib/fake_sqs/error_response.rb
|