From 91562e2111688f40d4e931085995bd7a97e450ef Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 26 Dec 2011 17:24:44 -0800 Subject: [PATCH] FileChecksum test --- test/unit/vagrant/util/file_checksum_test.rb | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/unit/vagrant/util/file_checksum_test.rb diff --git a/test/unit/vagrant/util/file_checksum_test.rb b/test/unit/vagrant/util/file_checksum_test.rb new file mode 100644 index 000000000..fa20d800b --- /dev/null +++ b/test/unit/vagrant/util/file_checksum_test.rb @@ -0,0 +1,23 @@ +require File.expand_path("../../../base", __FILE__) +require 'digest/md5' +require 'digest/sha1' + +require 'vagrant/util/file_checksum' + +describe FileChecksum do + include_context "unit" + + let(:environment) { isolated_environment } + + it "should return a valid checksum for a file" do + file = environment.workdir.join("file") + file.open("w+") { |f| f.write("HELLO!") } + + # Check multiple digests + instance = described_class.new(file, Digest::MD5) + instance.checksum.should == "9ac96c64417b5976a58839eceaa77956" + + instance = described_class.new(file, Digest::SHA1) + instance.checksum.should == "264b207c7913e461c43d0f63d2512f4017af4755" + end +end