ruby-sfn-local 0.1.10 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sfn/execution_log.rb +5 -4
- data/lib/sfn/mock_macros/sqs.rb +25 -0
- data/lib/sfn/state_machine.rb +4 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75dd7b0209a27d5fedaac3a899ab43ce8c9cc814ae8736e9ebfab57e11a81397
|
4
|
+
data.tar.gz: a4caabe1ecab7fbae2b9a71d3ddd760f95c709813d67c67972248cd15d7628b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46d027dcc3ba4688427c36f35ffd40c725a6edef9727320aea01c7c6c100f8dc2933dbe01437104d71546b037ea7830458dccb3e14b1be7cb443c47628077298
|
7
|
+
data.tar.gz: 77cc4a235b5e881fac19faff75c9a36c2d57ef08b95a7c941d214bb823166db9149f9e53241a51436ec94c0d8e85965564dbe9caa0b40c3f2caae0fbe2a8fe02
|
data/lib/sfn/execution_log.rb
CHANGED
@@ -19,6 +19,7 @@ module Sfn
|
|
19
19
|
|
20
20
|
def self.parse(execution_arn)
|
21
21
|
profile = {}
|
22
|
+
root_state_name = {}
|
22
23
|
output = nil
|
23
24
|
error = nil
|
24
25
|
state_name = nil
|
@@ -26,19 +27,19 @@ module Sfn
|
|
26
27
|
{ 'execution-arn': execution_arn.to_s, query: "'events[?#{EVENTS.join(' || ')}]'" })
|
27
28
|
JSON.parse(events_json).each do |event|
|
28
29
|
parsed_event = new(event)
|
29
|
-
|
30
30
|
output ||= parsed_event.output
|
31
31
|
error ||= parsed_event.error(events_json)
|
32
|
-
last_state_name = state_name
|
33
32
|
state_name = parsed_event.state_name
|
34
33
|
|
35
34
|
unless state_name.nil?
|
36
35
|
profile[state_name] ||= { 'input' => [], 'output' => [], 'parameters' => [] }
|
37
36
|
profile[state_name]['input'] << parsed_event.profile['input'] unless parsed_event.profile['input'].nil?
|
38
37
|
profile[state_name]['output'] << parsed_event.profile['output'] unless parsed_event.profile['output'].nil?
|
38
|
+
root_state_name[parsed_event.event['id']] = state_name
|
39
39
|
end
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
if !root_state_name[parsed_event.event['previousEventId']].nil? && !parsed_event.profile['parameters'].nil?
|
42
|
+
profile[root_state_name[parsed_event.event['previousEventId']]]['parameters'] << parsed_event.profile['parameters']
|
42
43
|
end
|
43
44
|
end
|
44
45
|
[output, profile]
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sfn
|
4
|
+
module MockMacros
|
5
|
+
module Sqs
|
6
|
+
def self.response(data)
|
7
|
+
data = [data] if data.is_a?(Hash)
|
8
|
+
data.map! do |val|
|
9
|
+
if val.key?(:error)
|
10
|
+
{ Throw: { Error: val[:error], Cause: val[:cause] } }
|
11
|
+
else
|
12
|
+
val[:uuid] ||= SecureRandom.uuid
|
13
|
+
val[:sequence] ||= 10_000_000_000_000_003_000
|
14
|
+
{ Return: { MessageId: val[:uuid], SequenceNumber: val[:sequence] } }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
out = {}
|
18
|
+
data.each_with_index do |val, idx|
|
19
|
+
out[idx.to_s] = val
|
20
|
+
end
|
21
|
+
out
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/sfn/state_machine.rb
CHANGED
@@ -29,7 +29,7 @@ module Sfn
|
|
29
29
|
|
30
30
|
def initialize(name, arn = nil)
|
31
31
|
self.path = "#{Sfn.configuration.definition_path}/#{name}.json"
|
32
|
-
self.name = name.split(
|
32
|
+
self.name = name.split('/').last
|
33
33
|
self.arn = arn || self.class.find_by_name(self.name)&.arn || create_state_machine
|
34
34
|
self.executions = {}
|
35
35
|
end
|
@@ -41,7 +41,7 @@ module Sfn
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def run(mock_data = {}, input = {}, test_name = nil)
|
44
|
-
test_name ||= OpenSSL::Digest::SHA512.digest(mock_data.merge(input).to_json)
|
44
|
+
test_name ||= OpenSSL::Digest::SHA512.digest(mock_data.merge({ input: input }).to_json)
|
45
45
|
executions[test_name] ||= Execution.call(self, test_name, mock_data, input)
|
46
46
|
executions[test_name]
|
47
47
|
end
|
@@ -63,8 +63,8 @@ module Sfn
|
|
63
63
|
|
64
64
|
def load_definition
|
65
65
|
local_definition_path = Tempfile.new(['name', '.json']).path
|
66
|
-
|
67
|
-
definition = File.read(
|
66
|
+
|
67
|
+
definition = File.read(path)
|
68
68
|
local_definition = definition.gsub(/"MaxConcurrency": [0-9]+/, '"MaxConcurrency": 1')
|
69
69
|
|
70
70
|
File.open(local_definition_path, 'w') { |file| file.puts local_definition }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-sfn-local
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gianni Mazza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-release
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/sfn/mock_macros/api_gateway.rb
|
70
70
|
- lib/sfn/mock_macros/lambda.rb
|
71
71
|
- lib/sfn/mock_macros/sns.rb
|
72
|
+
- lib/sfn/mock_macros/sqs.rb
|
72
73
|
- lib/sfn/mock_macros/step_function.rb
|
73
74
|
- lib/sfn/state_machine.rb
|
74
75
|
- lib/string.rb
|