providers/docker: Add usability test

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2019-05-27 21:39:04 -07:00
parent 25e11650c3
commit 7980178d19
2 changed files with 13 additions and 0 deletions

View File

@ -11,6 +11,14 @@ module VagrantPlugins
class Provider < Vagrant.plugin("2", :provider)
@@host_vm_mutex = Mutex.new
def self.usable?(raise_error=false)
Driver.new.execute("docker", "version")
true
rescue Vagrant::Errors::CommandUnavailable, Errors::ExecuteError
raise if raise_error
return false
end
def initialize(machine)
@logger = Log4r::Logger.new("vagrant::provider::docker")
@machine = machine

View File

@ -28,6 +28,11 @@ shared_context "virtualbox" do
allow(subprocess).to receive(:execute).
with("VBoxManage", "showvminfo", kind_of(String), kind_of(Hash)).
and_return(subprocess_result(exit_code: 0))
# apparently this is also used in docker tests
allow(subprocess).to receive(:execute).
with("docker", "version", an_instance_of(Hash)).
and_return(subprocess_result(exit_code: 0))
end
around do |example|