Try to mock up docker version subprocess result in test

This commit is contained in:
Brian Cain 2019-09-11 09:36:11 -07:00
parent d4002aa74d
commit c7b1f8821d
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
4 changed files with 48 additions and 0 deletions

View File

@ -66,6 +66,18 @@ describe VagrantPlugins::DockerProvider::Action::ConnectNetworks do
subject { described_class.new(app, env) } subject { described_class.new(app, env) }
let(:subprocess_result) do
double("subprocess_result").tap do |result|
allow(result).to receive(:exit_code).and_return(0)
allow(result).to receive(:stdout).and_return("")
allow(result).to receive(:stderr).and_return("")
end
end
before do
allow(Vagrant::Util::Subprocess).to receive(:execute).with("docker", "version", an_instance_of(Hash)).and_return(subprocess_result)
end
after do after do
sandbox.close sandbox.close
end end

View File

@ -55,6 +55,18 @@ describe VagrantPlugins::DockerProvider::Action::DestroyNetwork do
subject { described_class.new(app, env) } subject { described_class.new(app, env) }
let(:subprocess_result) do
double("subprocess_result").tap do |result|
allow(result).to receive(:exit_code).and_return(0)
allow(result).to receive(:stdout).and_return("")
allow(result).to receive(:stderr).and_return("")
end
end
before do
allow(Vagrant::Util::Subprocess).to receive(:execute).with("docker", "version", an_instance_of(Hash)).and_return(subprocess_result)
end
after do after do
sandbox.close sandbox.close
end end

View File

@ -43,6 +43,18 @@ describe VagrantPlugins::DockerProvider::Action::Login do
subject { described_class.new(app, env) } subject { described_class.new(app, env) }
let(:subprocess_result) do
double("subprocess_result").tap do |result|
allow(result).to receive(:exit_code).and_return(0)
allow(result).to receive(:stdout).and_return("")
allow(result).to receive(:stderr).and_return("")
end
end
before do
allow(Vagrant::Util::Subprocess).to receive(:execute).with("docker", "version", an_instance_of(Hash)).and_return(subprocess_result)
end
after do after do
sandbox.close sandbox.close
end end

View File

@ -67,6 +67,18 @@ describe VagrantPlugins::DockerProvider::Action::PrepareNetworks do
subject { described_class.new(app, env) } subject { described_class.new(app, env) }
let(:subprocess_result) do
double("subprocess_result").tap do |result|
allow(result).to receive(:exit_code).and_return(0)
allow(result).to receive(:stdout).and_return("")
allow(result).to receive(:stderr).and_return("")
end
end
before do
allow(Vagrant::Util::Subprocess).to receive(:execute).with("docker", "version", an_instance_of(Hash)).and_return(subprocess_result)
end
after do after do
sandbox.close sandbox.close
end end