From d71a78eacf1990f7f75793088493beac7ca8d9a2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 21 Nov 2011 21:55:03 -0800 Subject: [PATCH] Failing acceptance test for GH-564 --- test/acceptance/support/output.rb | 6 +++++ test/acceptance/up_with_box_url.rb | 36 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 test/acceptance/up_with_box_url.rb diff --git a/test/acceptance/support/output.rb b/test/acceptance/support/output.rb index 6af836517..1e3bf1aaa 100644 --- a/test/acceptance/support/output.rb +++ b/test/acceptance/support/output.rb @@ -60,5 +60,11 @@ module Acceptance def vm_destroyed @text =~ /Destroying VM and associated drives...$/ end + + # This checks that the "up" output properly contains text showing that + # it is downloading the box during the up process. + def up_fetching_box(name) + @text =~ /Box #{name} was not found. Fetching box from specified URL...$/ + end end end diff --git a/test/acceptance/up_with_box_url.rb b/test/acceptance/up_with_box_url.rb new file mode 100644 index 000000000..cb3b78be7 --- /dev/null +++ b/test/acceptance/up_with_box_url.rb @@ -0,0 +1,36 @@ +require File.expand_path("../base", __FILE__) +require "support/shared/command_examples" + +describe "vagrant up", "with a box URL set" do + include_context "acceptance" + + it "downloads and brings up the VM if the box doesn't exist" do + require_box("default") + + assert_execute("vagrant", "init", "base", box_path("default")) + result = assert_execute("vagrant", "up") + result.stdout.should match_output(:up_fetching_box, "base") + end + + it "downloads the file only once and works if shared by multiple VMs" do + require_box("default") + + environment.workdir.join("Vagrantfile").open("w+") do |f| + f.puts(<<-VFILE) +Vagrant::Config.run do |config| + config.vm.define :machine1 do |vm_config| + vm_config.vm.box = "base" + vm_config.vm.box_url = "#{box_path("default")}" + end + + config.vm.define :machine2 do |vm_config| + vm_config.vm.box = "base" + vm_config.vm.box_url = "#{box_path("default")}" + end +end +VFILE + end + + result = assert_execute("vagrant", "up") + end +end