Checking if a box already exists at the checking middleware
This commit is contained in:
parent
0c5c938250
commit
23296093b1
|
@ -0,0 +1,21 @@
|
|||
module Vagrant
|
||||
class Action
|
||||
module VM
|
||||
class Check
|
||||
def initialize(app, env)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
box_name = env["config"].vm.box
|
||||
|
||||
env.logger.info "Checking if the box '#{box_name}' was already downloaded"
|
||||
|
||||
box = Vagrant::Box.find(env.env , box_name)
|
||||
env.logger.info "The box #{box} were found"
|
||||
@app.call(env)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,25 @@
|
|||
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||
|
||||
|
||||
class CheckVMActionTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Action::VM::Check
|
||||
@app, @env = mock_action_data
|
||||
@instance = @klass.new(@app, @env)
|
||||
|
||||
@env['config'].vm.box = "foo"
|
||||
end
|
||||
should "check if the box exist" do
|
||||
Vagrant::Box.expects("find").with(@env.env, 'foo')
|
||||
@instance.call(@env)
|
||||
end
|
||||
|
||||
|
||||
should 'continue the chain process' do
|
||||
Vagrant::Box.stubs('find').with(@env.env, 'foo')
|
||||
@app.expects(:call).with(@env).once
|
||||
@instance.call(@env)
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue