ruby-sfn-local 0.1.14 → 0.1.17

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: 4a8d8a6fc30d2a2965dfda5c56c1aad5af809b7599f829828c829cf9930efbaf
4
+ data.tar.gz: ac740780539e3c0f93a7f3613f5b332f727d063bbbc63476b50c19c536489418
5
5
  SHA512:
6
- metadata.gz: fff1c781578513f06501c8e01c25d72ea30ede3515170e17c4d86fa4f6d0fe6da27a6e0b26d87882c8152c4a343d3a65052b0ab30d183168799bc02d42cb2e41
7
- data.tar.gz: 2df1e930018156d74acdfadc64d9c9f4bfa63a3c27190067562e556856cc982b1e8df4c8a7f1a554679912115527411043d56c5a733019ead05cd16c89313806
6
+ metadata.gz: f0f125829bc0d612a8dfd84f06434434ff684e61cdc51328af8c2ffe0df809cfbf00141d5d436b6a091ecb1413a3b1c58da097eae2b0fbd0fddab7c7e2be7b78
7
+ data.tar.gz: 1b1de6bb7d076d4930594eb5d153c1e243067d5c48f17376a5e500b3d9988679009caa24d34174f3dd3d9c6104b14fa66ddd93ce016b6dda9dcac835c6b3ff46
data/lib/sfn/execution.rb CHANGED
@@ -4,8 +4,8 @@ module Sfn
4
4
  class Execution
5
5
  attr_accessor :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)
@@ -14,14 +14,15 @@ module Sfn
14
14
  self.test_case = test_case.camelize
15
15
  end
16
16
 
17
- def exec(mock_data, input)
17
+ def exec(mock_data, input, dry_run = false)
18
18
  MockData.write_context(state_machine.name, test_case, mock_data)
19
19
  self.arn = AwsCli.run('stepfunctions', 'start-execution',
20
20
  { name: uuid,
21
21
  'state-machine': "#{state_machine.arn}##{test_case}",
22
- input: "'#{input.to_json}'" },
22
+ input: "'#{input.to_json}'"
23
+ },
23
24
  'executionArn')
24
- self.output, self.profile = ExecutionLog.parse(arn)
25
+ self.output, self.profile = ExecutionLog.parse(arn, dry_run)
25
26
  self
26
27
  end
27
28
  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,7 +1,7 @@
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.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gianni Mazza