Skip to content

Commit

Permalink
Add rspec tests for deployment unlock method
Browse files Browse the repository at this point in the history
  • Loading branch information
krauselukas committed Feb 25, 2021
1 parent 08b1ef1 commit be7004e
Show file tree
Hide file tree
Showing 4 changed files with 2,082 additions and 0 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions spec/obs_github_deployments/deployment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,41 @@
end
end
end

describe "unlock" do
context "with an deployment not in the locked state" do
before do
subject.send :create_and_set_state, state: "success", payload: nil
end

it "throws an exception" do
expect { subject.unlock }.to raise_error(
ObsGithubDeployments::Deployment::NothingToUnlockError
)
end
end

context "with an deployment without any state set" do
before do
subject.send :create, payload: nil
end

it "throws an exception" do
expect { subject.unlock }.to raise_error(
ObsGithubDeployments::Deployment::NothingToUnlockError
)
end
end

context "with a locked deployment in place" do
before do
subject.send :create_and_set_state, state: "queued", payload: nil
end

it "unlocks the deployment and returns true" do
expect(subject.unlock).to eq(true)
expect(subject.send(:latest_status).state).to eq("inactive")
end
end
end
end

0 comments on commit be7004e

Please sign in to comment.