fake_sqs 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fake_sqs.gemspec +2 -0
- data/lib/fake_sqs/actions/create_queue.rb +2 -1
- data/lib/fake_sqs/actions/get_queue_url.rb +2 -1
- data/lib/fake_sqs/actions/list_queues.rb +2 -1
- data/lib/fake_sqs/api.rb +2 -2
- data/lib/fake_sqs/error_response.rb +1 -1
- data/lib/fake_sqs/error_responses.yml +0 -1
- data/lib/fake_sqs/queue.rb +1 -0
- data/lib/fake_sqs/queues.rb +0 -1
- data/lib/fake_sqs/responder.rb +1 -1
- data/lib/fake_sqs/server.rb +4 -1
- data/lib/fake_sqs/test_integration.rb +7 -3
- data/lib/fake_sqs/version.rb +1 -1
- data/lib/fake_sqs/web_interface.rb +3 -4
- data/spec/integration_spec_helper.rb +2 -1
- data/spec/unit/api_spec.rb +2 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc20ac34a0c6c8147c3af9692169ae145b7d2e9c
|
4
|
+
data.tar.gz: 2964e38cee5d603014a322e514cfa63989cf66a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bafd8828d1f473c9a881d4c00a07f9e447bc6153869adbad17ae2d60fb97f5c248558122830ed66635f48b563c5eebb7fd4ce37eba7bc66ea95b6036e8fe6c0
|
7
|
+
data.tar.gz: e1ec826376dfb67c9f1f910903bf6852e66b73f2821014fe11e773aed50cea51251eed804d69ca99ea24cac3c8515786cf0932edc4cb0187314d7d0e2cb069fa
|
data/fake_sqs.gemspec
CHANGED
@@ -6,13 +6,14 @@ module FakeSQS
|
|
6
6
|
@server = options.fetch(:server)
|
7
7
|
@queues = options.fetch(:queues)
|
8
8
|
@responder = options.fetch(:responder)
|
9
|
+
@request = options.fetch(:request)
|
9
10
|
end
|
10
11
|
|
11
12
|
def call(params)
|
12
13
|
name = params.fetch("QueueName")
|
13
14
|
queue = @queues.create(name, params)
|
14
15
|
@responder.call :CreateQueue do |xml|
|
15
|
-
xml.QueueUrl @server.url_for(queue.name)
|
16
|
+
xml.QueueUrl @server.url_for(queue.name, {:host => @request.host, :port => @request.port})
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -6,13 +6,14 @@ module FakeSQS
|
|
6
6
|
@server = options.fetch(:server)
|
7
7
|
@queues = options.fetch(:queues)
|
8
8
|
@responder = options.fetch(:responder)
|
9
|
+
@request = options.fetch(:request)
|
9
10
|
end
|
10
11
|
|
11
12
|
def call(params)
|
12
13
|
name = params.fetch("QueueName")
|
13
14
|
queue = @queues.get(name, params)
|
14
15
|
@responder.call :GetQueueUrl do |xml|
|
15
|
-
xml.QueueUrl @server.url_for(queue.name)
|
16
|
+
xml.QueueUrl @server.url_for(queue.name, {:host => @request.host, :port => @request.port})
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -6,13 +6,14 @@ module FakeSQS
|
|
6
6
|
@server = options.fetch(:server)
|
7
7
|
@queues = options.fetch(:queues)
|
8
8
|
@responder = options.fetch(:responder)
|
9
|
+
@request = options.fetch(:request)
|
9
10
|
end
|
10
11
|
|
11
12
|
def call(params)
|
12
13
|
found = @queues.list(params)
|
13
14
|
@responder.call :ListQueues do |xml|
|
14
15
|
found.each do |queue|
|
15
|
-
xml.QueueUrl @server.url_for(queue.name)
|
16
|
+
xml.QueueUrl @server.url_for(queue.name, {:host => @request.host, :port => @request.port})
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
data/lib/fake_sqs/api.rb
CHANGED
@@ -34,9 +34,9 @@ module FakeSQS
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
def call(action, *args)
|
37
|
+
def call(action, request, *args)
|
38
38
|
if FakeSQS::Actions.const_defined?(action)
|
39
|
-
action = FakeSQS::Actions.const_get(action).new(options)
|
39
|
+
action = FakeSQS::Actions.const_get(action).new(options.merge({:request => request}))
|
40
40
|
queues.transaction do
|
41
41
|
action.call(*args)
|
42
42
|
end
|
data/lib/fake_sqs/queue.rb
CHANGED
data/lib/fake_sqs/queues.rb
CHANGED
data/lib/fake_sqs/responder.rb
CHANGED
data/lib/fake_sqs/server.rb
CHANGED
@@ -25,7 +25,7 @@ module FakeSQS
|
|
25
25
|
def start!
|
26
26
|
args = [ binfile, "-p", port.to_s, verbose, logging, "--database", database, { :out => out, :err => out } ].flatten.compact
|
27
27
|
@pid = Process.spawn(*args)
|
28
|
-
wait_until_up
|
28
|
+
wait_until_up(Time.now + start_timeout)
|
29
29
|
end
|
30
30
|
|
31
31
|
def stop
|
@@ -70,6 +70,10 @@ module FakeSQS
|
|
70
70
|
options.fetch(:database)
|
71
71
|
end
|
72
72
|
|
73
|
+
def start_timeout
|
74
|
+
options[:start_timeout] || 2
|
75
|
+
end
|
76
|
+
|
73
77
|
def verbose
|
74
78
|
if debug?
|
75
79
|
"--verbose"
|
@@ -86,10 +90,10 @@ module FakeSQS
|
|
86
90
|
end
|
87
91
|
end
|
88
92
|
|
89
|
-
def wait_until_up(deadline
|
93
|
+
def wait_until_up(deadline)
|
90
94
|
fail "FakeSQS didn't start in time" if Time.now > deadline
|
91
95
|
unless up?
|
92
|
-
sleep 0.
|
96
|
+
sleep 0.1
|
93
97
|
wait_until_up(deadline)
|
94
98
|
end
|
95
99
|
end
|
data/lib/fake_sqs/version.rb
CHANGED
@@ -36,17 +36,16 @@ module FakeSQS
|
|
36
36
|
end
|
37
37
|
|
38
38
|
handle "/", [:get, :post] do
|
39
|
-
params['logger'] = logger
|
40
39
|
if params['QueueUrl']
|
41
40
|
queue = URI.parse(params['QueueUrl']).path.gsub(/\//, '')
|
42
|
-
return settings.api.call(action, queue, params) unless queue.empty?
|
41
|
+
return settings.api.call(action, request, queue, params) unless queue.empty?
|
43
42
|
end
|
44
43
|
|
45
|
-
settings.api.call(action, params)
|
44
|
+
settings.api.call(action, request, params)
|
46
45
|
end
|
47
46
|
|
48
47
|
handle "/:queue", [:get, :post] do |queue|
|
49
|
-
settings.api.call(action, queue, params)
|
48
|
+
settings.api.call(action, request, queue, params)
|
50
49
|
end
|
51
50
|
end
|
52
51
|
end
|
@@ -11,8 +11,9 @@ puts "\n\e[34mRunning specs with database \e[33m#{db}\e[0m"
|
|
11
11
|
|
12
12
|
$fake_sqs = FakeSQS::TestIntegration.new(
|
13
13
|
database: db,
|
14
|
-
sqs_endpoint: "
|
14
|
+
sqs_endpoint: "0.0.0.0",
|
15
15
|
sqs_port: 4568,
|
16
|
+
start_timeout: 2,
|
16
17
|
)
|
17
18
|
|
18
19
|
RSpec.configure do |config|
|
data/spec/unit/api_spec.rb
CHANGED
@@ -19,9 +19,9 @@ RSpec.describe FakeSQS::API do
|
|
19
19
|
allow(queues).to receive(:transaction).and_yield
|
20
20
|
api = FakeSQS::API.new(:queues => queues)
|
21
21
|
|
22
|
-
response = api.call("TheAction", {:foo => "bar"})
|
22
|
+
response = api.call("TheAction", {}, {:foo => "bar"})
|
23
23
|
|
24
|
-
expect(response[:options]).to eq :queues => queues
|
24
|
+
expect(response[:options]).to eq :queues => queues, :request => {}
|
25
25
|
expect(response[:params]).to eq :foo => "bar"
|
26
26
|
end
|
27
27
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake_sqs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: sinatra
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|