Catch nil input for querying machine index
This commit is contained in:
parent
ce1fb54a04
commit
e619a6a930
@ -263,6 +263,7 @@ module Vagrant
|
||||
#
|
||||
# @return [Hash]
|
||||
def find_by_prefix(prefix)
|
||||
return nil if prefix.nil?
|
||||
@machines.each do |uuid, data|
|
||||
return data.merge("id" => uuid) if uuid.start_with?(prefix)
|
||||
end
|
||||
|
||||
@ -105,6 +105,7 @@ describe Vagrant::MachineIndex do
|
||||
|
||||
it "returns nil if the machine doesn't exist" do
|
||||
expect(subject.get("foo")).to be_nil
|
||||
expect(subject.get(nil)).to be_nil
|
||||
end
|
||||
|
||||
it "returns a valid entry if the machine exists" do
|
||||
@ -139,6 +140,11 @@ describe Vagrant::MachineIndex do
|
||||
expect(subject.include?("b")).to be(true)
|
||||
end
|
||||
|
||||
it "should return false if given nil input" 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