Merge pull request #12188 from soapy1/vagrant-does-not-reference-empty-string-vm
Don't try to find "" by prefix in the machine index
This commit is contained in:
commit
d111596446
@ -263,7 +263,7 @@ module Vagrant
|
||||
#
|
||||
# @return [Hash]
|
||||
def find_by_prefix(prefix)
|
||||
return if !prefix
|
||||
return if !prefix || prefix == ""
|
||||
@machines.each do |uuid, data|
|
||||
return data.merge("id" => uuid) if uuid.start_with?(prefix)
|
||||
end
|
||||
|
||||
@ -164,11 +164,18 @@ describe VagrantPlugins::CommandDestroy::Command do
|
||||
subject.execute
|
||||
end
|
||||
|
||||
context "with an invalid argument" do
|
||||
context "with machine that does not exist" do
|
||||
let(:argv){ ["notweb"] }
|
||||
it "raises an exception" do
|
||||
expect { subject.execute }.to raise_error(Vagrant::Errors::MachineNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
context "with an invalid argument" do
|
||||
let(:argv){ [""] }
|
||||
it "raises an exception" do
|
||||
expect { subject.execute }.to raise_error(Vagrant::Errors::MachineNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -108,6 +108,11 @@ describe Vagrant::MachineIndex do
|
||||
expect(subject.get(nil)).to be_nil
|
||||
end
|
||||
|
||||
it "returns nil if the machine doesn't exist (is an empty string)" do
|
||||
expect(subject.get("")).to be_nil
|
||||
expect(subject.get(nil)).to be_nil
|
||||
end
|
||||
|
||||
it "returns a valid entry if the machine exists" do
|
||||
result = subject.get("bar")
|
||||
|
||||
@ -144,7 +149,6 @@ describe Vagrant::MachineIndex do
|
||||
expect(subject.include?(nil)).to be(false)
|
||||
end
|
||||
|
||||
|
||||
it "locks the entry so subsequent gets fail" do
|
||||
result = subject.get("bar")
|
||||
expect(result).to_not be_nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user