ruby-sfn-local 0.1.14 → 0.1.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebdc76d783d70c6ffd4a53ad77d2ccad609f51454b6d8888cc03b71c9d2a3f8a
4
- data.tar.gz: 8d4bd280dab1cc12fb4bd2fb25995c6afb4096ed7862d65df6a7d7c10c57483c
3
+ metadata.gz: 184760e30916c0f301d4bc438b66f213c75774987df81472cf3a7c05dbbc0b3d
4
+ data.tar.gz: 7d6c7cf307eec32ade24d3a472c2f0dc396ece10daf296af401ce8d7d5fa7023
5
5
  SHA512:
6
- metadata.gz: fff1c781578513f06501c8e01c25d72ea30ede3515170e17c4d86fa4f6d0fe6da27a6e0b26d87882c8152c4a343d3a65052b0ab30d183168799bc02d42cb2e41
7
- data.tar.gz: 2df1e930018156d74acdfadc64d9c9f4bfa63a3c27190067562e556856cc982b1e8df4c8a7f1a554679912115527411043d56c5a733019ead05cd16c89313806
6
+ metadata.gz: 4a78367ca2df85472e6a090e5aac5d0d5c2707828a1a5d852c74aa9afb1ba05820a56192103743556856b6af92bccc234a6de1fd9a4c4d43d3a887bb808693e2
7
+ data.tar.gz: 332a9ab75391af1b4b106bca9f28ae4f9203d30a2506c180be3750cddf9239160d80559d1e9c027cced1f95675ab589f4e87fbaf393751b6860dbdb250a55ed4
data/lib/sfn/execution.rb CHANGED
@@ -2,26 +2,28 @@
2
2
 
3
3
  module Sfn
4
4
  class Execution
5
- attr_accessor :uuid, :state_machine, :test_case, :arn, :output, :profile
5
+ attr_accessor :id, :uuid, :state_machine, :test_case, :arn, :output, :profile
6
6
 
7
- def self.call(state_machine, test_case, mock_data, input)
8
- new(state_machine, test_case).exec(mock_data, input)
7
+ def self.call(state_machine, test_case, mock_data, input, dry_run = false)
8
+ new(state_machine, test_case).exec(mock_data, input, dry_run)
9
9
  end
10
10
 
11
11
  def initialize(state_machine, test_case)
12
12
  self.uuid = SecureRandom.uuid
13
13
  self.state_machine = state_machine
14
+ self.id = "#{self.state_machine.arn.gsub("stateMachine","execution")}:#{self.uuid}"
14
15
  self.test_case = test_case.camelize
15
16
  end
16
17
 
17
- def exec(mock_data, input)
18
+ def exec(mock_data, input, dry_run = false)
18
19
  MockData.write_context(state_machine.name, test_case, mock_data)
19
20
  self.arn = AwsCli.run('stepfunctions', 'start-execution',
20
21
  { name: uuid,
21
22
  'state-machine': "#{state_machine.arn}##{test_case}",
22
- input: "'#{input.to_json}'" },
23
+ input: "'#{input.to_json}'"
24
+ },
23
25
  'executionArn')
24
- self.output, self.profile = ExecutionLog.parse(arn)
26
+ self.output, self.profile = ExecutionLog.parse(arn, dry_run)
25
27
  self
26
28
  end
27
29
  end
@@ -17,7 +17,7 @@ module Sfn
17
17
  EVENTS = %w[stateEnteredEventDetails stateExitedEventDetails executionSucceededEventDetails
18
18
  executionFailedEventDetails taskScheduledEventDetails].freeze
19
19
 
20
- def self.parse(execution_arn)
20
+ def self.parse(execution_arn, dry_run = false)
21
21
  profile = {}
22
22
  root_state_name = {}
23
23
  output = nil
@@ -28,7 +28,7 @@ module Sfn
28
28
  JSON.parse(events_json).each do |event|
29
29
  parsed_event = new(event)
30
30
  output ||= parsed_event.output
31
- error ||= parsed_event.error(events_json)
31
+ error ||= parsed_event.error(events_json, dry_run)
32
32
  state_name = parsed_event.state_name
33
33
 
34
34
  unless state_name.nil?
@@ -57,12 +57,14 @@ module Sfn
57
57
  try_parse(event.dig('executionSucceededEventDetails', 'output'))
58
58
  end
59
59
 
60
- def error(events_json = '{}')
60
+ def error(events_json = '{}', dry_run = false)
61
61
  return if event['executionFailedEventDetails'].nil?
62
62
 
63
63
  raise ExecutionError.new(event['executionFailedEventDetails']['cause'],
64
- event['executionFailedEventDetails']['error'],
65
- events_json)
64
+ event['executionFailedEventDetails']['error'],
65
+ events_json) unless dry_run
66
+
67
+ event['executionFailedEventDetails']
66
68
  end
67
69
 
68
70
  def profile
@@ -40,9 +40,13 @@ module Sfn
40
40
  Collection.instance.delete_by_arn(arn)
41
41
  end
42
42
 
43
- def run(mock_data = {}, input = {}, test_name = nil)
43
+ def dry_run(mock_data = {}, input = {}, test_name = nil)
44
+ execution = run(mock_data, input, test_name, true)
45
+ end
46
+
47
+ def run(mock_data = {}, input = {}, test_name = nil, dry_run = false)
44
48
  test_name ||= OpenSSL::Digest::SHA512.digest(mock_data.merge({ input: input }).to_json)
45
- executions[test_name] ||= Execution.call(self, test_name, mock_data, input)
49
+ executions[test_name] ||= Execution.call(self, test_name, mock_data, input, dry_run)
46
50
  executions[test_name]
47
51
  end
48
52
 
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.14
4
+ version: 0.1.19
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-09-29 00:00:00.000000000 Z
11
+ date: 2022-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-release