Skip to content

Commit

Permalink
Workflow output should be JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Jun 24, 2024
1 parent be26ebc commit 4d5ea58
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/floe/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def run(args = ARGV)
# Display status
workflows.each do |workflow|
puts "", "#{workflow.name}#{" (#{workflow.status})" unless workflow.context.success?}", "===" if workflows.size > 1
puts workflow.output.inspect
puts workflow.output
end

workflows.all? { |workflow| workflow.context.success? }
Expand Down
2 changes: 1 addition & 1 deletion lib/floe/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def status
end

def output
context.output if end?
context.output.to_json if end?
end

def end?
Expand Down
14 changes: 7 additions & 7 deletions spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

lines = output.lines(:chomp => true)
expect(lines.first).to include("checking 1 workflows...")
expect(lines.last).to eq('{"foo"=>1}')
expect(lines.last).to eq('{"foo":1}')
end

it "with a bare workflow and --input" do
Expand All @@ -48,7 +48,7 @@

lines = output.lines(:chomp => true)
expect(lines.first).to include("checking 1 workflows...")
expect(lines.last).to eq('{"foo"=>1}')
expect(lines.last).to eq('{"foo":1}')
end

it "with --workflow and no input" do
Expand All @@ -66,7 +66,7 @@

lines = output.lines(:chomp => true)
expect(lines.first).to include("checking 1 workflows...")
expect(lines.last).to eq('{"foo"=>1}')
expect(lines.last).to eq('{"foo":1}')
end

it "with a bare workflow and --workflow" do
Expand Down Expand Up @@ -94,11 +94,11 @@
expect(lines.last(7).join("\n")).to eq(<<~OUTPUT.chomp)
workflow
===
{"foo"=>1}
{"foo":1}
workflow
===
{"foo"=>2}
{"foo":2}
OUTPUT
end

Expand All @@ -111,11 +111,11 @@
expect(lines.last(7).join("\n")).to eq(<<~OUTPUT.chomp)
workflow
===
{"foo"=>1}
{"foo":1}
workflow
===
{"foo"=>1}
{"foo":1}
OUTPUT
end

Expand Down
10 changes: 5 additions & 5 deletions spec/workflow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
expect(ctx.ended?).to eq(true)

# final results
expect(workflow.output).to eq(input)
expect(workflow.output).to eq(input.to_json)
expect(workflow.status).to eq("success")
expect(workflow.end?).to eq(true)
end
Expand All @@ -113,7 +113,7 @@
expect(ctx.ended?).to eq(true)

# final results
expect(workflow.output).to eq({"Cause" => "Bad Stuff", "Error" => "Issue"})
expect(workflow.output).to eq({"Error" => "Issue", "Cause" => "Bad Stuff"}.to_json)
expect(workflow.status).to eq("failure")
expect(workflow.end?).to eq(true)
end
Expand Down Expand Up @@ -148,7 +148,7 @@
workflow.start_workflow
workflow.step_nonblock

expect(workflow.output).to eq(input)
expect(workflow.output).to eq(input.to_json)
expect(workflow.status).to eq("success")
expect(workflow.end?).to eq(true)
expect(ctx.output).to eq(input)
Expand Down Expand Up @@ -187,7 +187,7 @@
# step_nonblock should return 0 and mark the workflow as completed
expect(workflow.step_nonblock).to eq(0)

expect(workflow.output).to eq(input)
expect(workflow.output).to eq(input.to_json)
expect(workflow.status).to eq("success")
expect(workflow.end?).to eq(true)
expect(ctx.output).to eq(input)
Expand Down Expand Up @@ -243,7 +243,7 @@
expect(ctx.running?).to eq(false)
expect(ctx.ended?).to eq(true)

expect(workflow.output).to eq(input)
expect(workflow.output).to eq(input.to_json)
end
end

Expand Down

0 comments on commit 4d5ea58

Please sign in to comment.