Some `vagrant box` tests
This commit is contained in:
parent
78f8705c5b
commit
c9cf2867ea
|
@ -3,6 +3,7 @@
|
|||
|
||||
# Vagrant stuff
|
||||
acceptance_config.yml
|
||||
package.box
|
||||
Vagrantfile
|
||||
.vagrant
|
||||
|
||||
|
|
|
@ -5,4 +5,18 @@ class BoxTest < AcceptanceTest
|
|||
result = execute("vagrant", "box", "list")
|
||||
assert result.stdout.read =~ /There are no installed boxes!/
|
||||
end
|
||||
|
||||
should "add a box from a file" do
|
||||
if !config.boxes.has_key?("default") || !File.file?(config.boxes["default"])
|
||||
raise ArgumentError, "The configuration should specify a 'default' box."
|
||||
end
|
||||
|
||||
# Add the box, which we expect to succeed
|
||||
results = execute("vagrant", "box", "add", "foo", config.boxes["default"])
|
||||
assert(results.success?, "Box add should succeed.")
|
||||
|
||||
# Verify that the box now shows up in the list of available boxes
|
||||
results = execute("vagrant", "box", "list")
|
||||
assert(results.stdout.read =~ /^foo$/, "Box should exist after it is added")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,6 +8,7 @@ module Acceptance
|
|||
attr_reader :vagrant_path
|
||||
attr_reader :vagrant_version
|
||||
attr_reader :env
|
||||
attr_reader :boxes
|
||||
|
||||
def initialize(path)
|
||||
@logger = Log4r::Logger.new("acceptance::config")
|
||||
|
@ -18,6 +19,26 @@ module Acceptance
|
|||
@vagrant_path = options["vagrant_path"]
|
||||
@vagrant_version = options["vagrant_version"]
|
||||
@env = options["env"]
|
||||
@boxes = options["boxes"]
|
||||
|
||||
# Verify the configuration object.
|
||||
validate
|
||||
end
|
||||
|
||||
# This method verifies the configuration and makes sure that
|
||||
# all the configuration is available and appears good. This
|
||||
# method will raise an ArgumentError in the case that anything
|
||||
# is wrong.
|
||||
def validate
|
||||
if !@vagrant_path || !File.file?(@vagrant_path)
|
||||
raise ArgumentError, "'vagrant_path' must point to the `vagrant` executable"
|
||||
elsif !@vagrant_version
|
||||
raise ArgumentError, "`vagrant_version' must be set to the version of the `vagrant` executable"
|
||||
end
|
||||
|
||||
if !@boxes || !@boxes.is_a?(Hash)
|
||||
raise ArgumentError, "`boxes` must be a dictionary of available boxes on the local filesystem."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -88,6 +88,10 @@ module Acceptance
|
|||
@stdout = stdout
|
||||
@stderr = stderr
|
||||
end
|
||||
|
||||
def success?
|
||||
@exit_status == 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue