Skip to content

Commit

Permalink
Merge pull request #170 from kbrock/workflow_comment
Browse files Browse the repository at this point in the history
add Workflow#comment
  • Loading branch information
agrare authored Apr 5, 2024
2 parents 6d5ddbe + 832df39 commit c1d732f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/floe/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def wait(workflows, timeout: nil, &block)
end
end

attr_reader :context, :credentials, :payload, :states, :states_by_name, :start_at, :name
attr_reader :context, :credentials, :payload, :states, :states_by_name, :start_at, :name, :comment

def initialize(payload, context = nil, credentials = {}, name = nil)
payload = JSON.parse(payload) if payload.kind_of?(String)
Expand All @@ -100,6 +100,7 @@ def initialize(payload, context = nil, credentials = {}, name = nil)
@payload = payload
@context = context
@credentials = credentials || {}
@comment = payload["Comment"]
@start_at = payload["StartAt"]

@states = payload["States"].to_a.map { |state_name, state| State.build!(self, state_name, state) }
Expand Down
12 changes: 12 additions & 0 deletions spec/workflow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,16 @@
end
end
end

describe "#comment" do
it "handles no comment" do
workflow = Floe::Workflow.new({"StartAt" => "First", "States" => {"First" => {"Type" => "Succeed"}}}, {})
expect(workflow.comment).to be nil
end

it "handles a comment" do
workflow = Floe::Workflow.new({"StartAt" => "First", "Comment" => "great stuff", "States" => {"First" => {"Type" => "Succeed"}}}, {})
expect(workflow.comment).to eq("great stuff")
end
end
end

0 comments on commit c1d732f

Please sign in to comment.