fake_sqs 0.0.8 → 0.0.9
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/bin/fake_sqs +2 -1
- data/lib/fake_sqs/actions/set_queue_attributes.rb +1 -1
- data/lib/fake_sqs/queue.rb +15 -3
- data/lib/fake_sqs/version.rb +1 -1
- data/spec/unit/queue_spec.rb +24 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c424f4af6489d03024c8cc27bc894df0ffd8e065
|
4
|
+
data.tar.gz: 81d0da9ebe28dd1d47808d14f91f6a0d490d0bef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f8286741675fb8beb9e8206ce5102bc82183386c5ea2297917fb44e9d03ff876265c1dd3c0838717fd7b34496e4de31becb0e1a7f276c155ccbf8b3619cc2cb
|
7
|
+
data.tar.gz: f0f65a2c48b86beb6a935843cff6c37fe38148a4723add4176a5c24f264ca9afd1ff5b60054ee6ad97f5b48fb89d4e8e380470a40ff537d4a57ef816de75cd50
|
data/bin/fake_sqs
CHANGED
data/lib/fake_sqs/queue.rb
CHANGED
@@ -6,16 +6,28 @@ 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, :arn
|
10
10
|
|
11
11
|
def initialize(options = {})
|
12
12
|
@name = options.fetch("QueueName")
|
13
13
|
@message_factory = options.fetch(:message_factory)
|
14
|
-
@
|
15
|
-
@
|
14
|
+
@arn = "arn:aws:sqs:us-east-1:#{SecureRandom.hex}:#{@name}"
|
15
|
+
@queue_attributes = {}
|
16
16
|
reset
|
17
17
|
end
|
18
18
|
|
19
|
+
def add_queue_attributes(attrs)
|
20
|
+
@queue_attributes.merge!(attrs)
|
21
|
+
end
|
22
|
+
|
23
|
+
def attributes
|
24
|
+
@queue_attributes.merge(
|
25
|
+
"QueueArn" => arn,
|
26
|
+
"ApproximateNumberOfMessages" => messages.size,
|
27
|
+
"ApproximateNumberOfMessagesNotVisible" => messages_in_flight.size,
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
19
31
|
def send_message(options = {})
|
20
32
|
message = message_factory.new(options)
|
21
33
|
messages << message
|
data/lib/fake_sqs/version.rb
CHANGED
data/spec/unit/queue_spec.rb
CHANGED
@@ -54,7 +54,7 @@ describe FakeSQS::Queue do
|
|
54
54
|
|
55
55
|
sample_group.times do
|
56
56
|
sent_first = send_message
|
57
|
-
|
57
|
+
_ = send_message
|
58
58
|
message = receive_message.values.first
|
59
59
|
if message == sent_first
|
60
60
|
indexes[:first] += 1
|
@@ -88,10 +88,18 @@ describe FakeSQS::Queue do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
it "keeps track of sent messages" do
|
91
|
+
|
91
92
|
send_message
|
93
|
+
|
92
94
|
queue.should have(0).messages_in_flight
|
95
|
+
queue.attributes["ApproximateNumberOfMessagesNotVisible"].should eq 0
|
96
|
+
queue.attributes["ApproximateNumberOfMessages"].should eq 1
|
97
|
+
|
93
98
|
receive_message
|
99
|
+
|
94
100
|
queue.should have(1).messages_in_flight
|
101
|
+
queue.attributes["ApproximateNumberOfMessagesNotVisible"].should eq 1
|
102
|
+
queue.attributes["ApproximateNumberOfMessages"].should eq 0
|
95
103
|
end
|
96
104
|
|
97
105
|
it "gets multiple message" do
|
@@ -117,7 +125,7 @@ describe FakeSQS::Queue do
|
|
117
125
|
describe "#delete_message" do
|
118
126
|
|
119
127
|
it "deletes by the receipt" do
|
120
|
-
|
128
|
+
send_message
|
121
129
|
receipt = receive_message.keys.first
|
122
130
|
|
123
131
|
queue.should have(1).messages_in_flight
|
@@ -132,6 +140,20 @@ describe FakeSQS::Queue do
|
|
132
140
|
|
133
141
|
end
|
134
142
|
|
143
|
+
describe "#add_queue_attributes" do
|
144
|
+
|
145
|
+
it "adds to it's queue attributes" do
|
146
|
+
queue.add_queue_attributes("foo" => "bar")
|
147
|
+
queue.attributes.should eq(
|
148
|
+
"foo" => "bar",
|
149
|
+
"QueueArn" => queue.arn,
|
150
|
+
"ApproximateNumberOfMessages" => 0,
|
151
|
+
"ApproximateNumberOfMessagesNotVisible" => 0
|
152
|
+
)
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
156
|
+
|
135
157
|
def send_message(options = {})
|
136
158
|
queue.send_message(options)
|
137
159
|
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.9
|
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-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|