Merge pull request #11183 from briancain/fixup/include-errors-in-checksum-util
Fixes #11179: Ensure Vagrant::Errors are loaded in file_checksum util
This commit is contained in:
commit
39ea1af5ab
|
@ -2,6 +2,9 @@
|
||||||
# passed into FileChecksum. Note that this isn't strictly enforced at
|
# passed into FileChecksum. Note that this isn't strictly enforced at
|
||||||
# the moment, and this class isn't directly used. It is merely here for
|
# the moment, and this class isn't directly used. It is merely here for
|
||||||
# documentation of structure of the class.
|
# documentation of structure of the class.
|
||||||
|
|
||||||
|
require "vagrant/errors"
|
||||||
|
|
||||||
class DigestClass
|
class DigestClass
|
||||||
def update(string); end
|
def update(string); end
|
||||||
def hexdigest; end
|
def hexdigest; end
|
||||||
|
@ -62,7 +65,7 @@ class FileChecksum
|
||||||
def load_digest(type)
|
def load_digest(type)
|
||||||
digest = CHECKSUM_MAP[type.to_s.to_sym]
|
digest = CHECKSUM_MAP[type.to_s.to_sym]
|
||||||
if digest.nil?
|
if digest.nil?
|
||||||
raise Errors::BoxChecksumInvalidType,
|
raise Vagrant::Errors::BoxChecksumInvalidType,
|
||||||
type: type.to_s
|
type: type.to_s
|
||||||
end
|
end
|
||||||
digest
|
digest
|
||||||
|
|
|
@ -32,4 +32,15 @@ describe FileChecksum do
|
||||||
expect(t_i.checksum).to eq(k_i.checksum)
|
expect(t_i.checksum).to eq(k_i.checksum)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with an invalid digest" do
|
||||||
|
let(:fake_digest) { :fake_digest }
|
||||||
|
|
||||||
|
it "should raise an exception if the box has an invalid checksum type" do
|
||||||
|
file = environment.workdir.join("file")
|
||||||
|
file.open("w+") { |f| f.write("HELLO!") }
|
||||||
|
|
||||||
|
expect{ described_class.new(file, fake_digest) }.to raise_error(Vagrant::Errors::BoxChecksumInvalidType)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue