Resume subcommand
This commit is contained in:
parent
5efa7bded5
commit
b72e3640e8
|
@ -0,0 +1,22 @@
|
|||
module Vagrant
|
||||
class Commands
|
||||
# Resume a running vagrant instance. This resumes an already suspended
|
||||
# instance (from {suspend}).
|
||||
#
|
||||
# This command requires that an instance already be brought up with
|
||||
# `vagrant up`.
|
||||
class Resume < Base
|
||||
Base.subcommand "resume", self
|
||||
description "Resumes a suspend vagrant environment"
|
||||
|
||||
def execute(args=[])
|
||||
env.require_persisted_vm
|
||||
env.vm.resume
|
||||
end
|
||||
|
||||
def options_spec(opts)
|
||||
opts.banner = "Usage: vagrant resume"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,33 @@
|
|||
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||
|
||||
class CommandsResumeTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Commands::Resume
|
||||
|
||||
@persisted_vm = mock("persisted_vm")
|
||||
@persisted_vm.stubs(:execute!)
|
||||
|
||||
@env = mock_environment
|
||||
@env.stubs(:require_persisted_vm)
|
||||
@env.stubs(:vm).returns(@persisted_vm)
|
||||
|
||||
@instance = @klass.new(@env)
|
||||
end
|
||||
|
||||
context "executing" do
|
||||
setup do
|
||||
@persisted_vm.stubs(:resume)
|
||||
@persisted_vm.stubs(:saved?).returns(true)
|
||||
end
|
||||
|
||||
should "require a persisted VM" do
|
||||
@env.expects(:require_persisted_vm).once
|
||||
@instance.execute
|
||||
end
|
||||
|
||||
should "save the state of the VM" do
|
||||
@persisted_vm.expects(:resume).once
|
||||
@instance.execute
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue