Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix workflow status when the workflow is pending to start #116

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/gush/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def status
when stopped?
:stopped
else
:running
:pending
end
end

Expand Down
24 changes: 23 additions & 1 deletion spec/gush/workflow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,28 @@ def configure(*args, **kwargs)
end
end

describe "#status" do
it "returns failed" do
subject.find_job('Prepare').fail!
expect(subject.status).to eq(:failed)
end
it "returns running" do
subject.find_job('Prepare').start!
expect(subject.status).to eq(:running)
end
it "returns finished" do
subject.jobs.each {|n| n.finish! }
expect(subject.status).to eq(:finished)
end
it "returns stopped" do
subject.stopped = true
expect(subject.status).to eq(:stopped)
end
it "returns pending" do
expect(subject.status).to eq(:pending)
end
end

describe "#to_json" do
it "returns correct hash" do
klass = Class.new(Gush::Workflow) do
Expand All @@ -112,7 +134,7 @@ def configure(*args)
"id" => an_instance_of(String),
"name" => klass.to_s,
"klass" => klass.to_s,
"status" => "running",
"status" => "pending",
"total" => 2,
"finished" => 0,
"started_at" => nil,
Expand Down