From 23bd397cb858492b21817fb40ce70bfdca9c465b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 1 Mar 2014 11:59:16 +0100 Subject: [PATCH] core: BoxMetadata supports checksums --- lib/vagrant/box_metadata.rb | 12 ++++++++++++ test/unit/vagrant/box_metadata_test.rb | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lib/vagrant/box_metadata.rb b/lib/vagrant/box_metadata.rb index 20562452a..81c040e4b 100644 --- a/lib/vagrant/box_metadata.rb +++ b/lib/vagrant/box_metadata.rb @@ -120,9 +120,21 @@ module Vagrant # @return [String] attr_accessor :url + # The checksum value for this box, if any. + # + # @return [String] + attr_accessor :checksum + + # The type of checksum (if any) associated with this provider. + # + # @return [String] + attr_accessor :checksum_type + def initialize(raw) @name = raw["name"] @url = raw["url"] + @checksum = raw["checksum"] + @checksum_type = raw["checksum_type"] end end end diff --git a/test/unit/vagrant/box_metadata_test.rb b/test/unit/vagrant/box_metadata_test.rb index 4ace29922..488effb91 100644 --- a/test/unit/vagrant/box_metadata_test.rb +++ b/test/unit/vagrant/box_metadata_test.rb @@ -154,4 +154,19 @@ describe Vagrant::BoxMetadata::Provider do expect(subject.url).to eq("bar") end end + + describe "#checksum and #checksum_type" do + it "is set properly" do + raw["checksum"] = "foo" + raw["checksum_type"] = "bar" + + expect(subject.checksum).to eq("foo") + expect(subject.checksum_type).to eq("bar") + end + + it "is nil if not set" do + expect(subject.checksum).to be_nil + expect(subject.checksum_type).to be_nil + end + end end