Class: Sfn::Execution

Inherits:
Object
  • Object
show all
Defined in:
lib/sfn/execution.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state_machine, test_case) ⇒ Execution

Returns a new instance of Execution.



11
12
13
14
15
# File 'lib/sfn/execution.rb', line 11

def initialize(state_machine, test_case)
  self.uuid = SecureRandom.uuid
  self.state_machine = state_machine
  self.test_case = test_case.camelize
end

Instance Attribute Details

#arnObject

Returns the value of attribute arn.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def arn
  @arn
end

#outputObject

Returns the value of attribute output.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def output
  @output
end

#profileObject

Returns the value of attribute profile.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def profile
  @profile
end

#state_machineObject

Returns the value of attribute state_machine.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def state_machine
  @state_machine
end

#test_caseObject

Returns the value of attribute test_case.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def test_case
  @test_case
end

#uuidObject

Returns the value of attribute uuid.



5
6
7
# File 'lib/sfn/execution.rb', line 5

def uuid
  @uuid
end

Class Method Details

.call(state_machine, test_case, mock_data, input) ⇒ Object



7
8
9
# File 'lib/sfn/execution.rb', line 7

def self.call(state_machine, test_case, mock_data, input)
  new(state_machine, test_case).exec(mock_data, input)
end

Instance Method Details

#exec(mock_data, input) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/sfn/execution.rb', line 17

def exec(mock_data, input)
  MockData.write_context(state_machine.name, test_case, mock_data)
  self.arn = AwsCli.run('stepfunctions', 'start-execution',
                        { name: uuid,
                          'state-machine': "#{state_machine.arn}##{test_case}",
                          input: "'#{input.to_json}'" },
                        'executionArn')
  self.output, self.profile = ExecutionLog.parse(arn)
  self
end