Skip to content

Commit

Permalink
Merge pull request #147 from mansam/handle-volume-double-deletion-error
Browse files Browse the repository at this point in the history
Handle attempts to delete volumes that have already been deleted
  • Loading branch information
aufi authored Nov 29, 2017
2 parents 64eeaba + 4bbbe1c commit 14fd2f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def raw_update_volume(options)
def validate_delete_volume
msg = validate_volume
return {:available => msg[:available], :message => msg[:message]} unless msg[:available]
if with_provider_object(&:status) == "in-use"
return validation_failed("Create Volume", "Can't delete volume that is in use.")
if status == "in-use"
return validation_failed("Delete Volume", "Can't delete volume that is in use.")
end
{:available => true, :message => nil}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@

context "#delete_volume" do
it "validates the volume delete operation when status is in-use" do
expect(the_raw_volume).to receive(:status).and_return("in-use")
expect(cloud_volume).to receive(:status).and_return("in-use")
validation = cloud_volume.validate_delete_volume
expect(validation[:available]).to be false
end

it "validates the volume delete operation when status is available" do
expect(the_raw_volume).to receive(:status).and_return("available")
expect(cloud_volume).to receive(:status).and_return("available")
validation = cloud_volume.validate_delete_volume
expect(validation[:available]).to be true
end

it "validates the volume delete operation when status is error" do
expect(the_raw_volume).to receive(:status).and_return("error")
expect(cloud_volume).to receive(:status).and_return("error")
validation = cloud_volume.validate_delete_volume
expect(validation[:available]).to be true
end
Expand Down

0 comments on commit 14fd2f9

Please sign in to comment.