Merge pull request #11607 from briancain/fixup/docker-install-test

Fixes #11606: Mock out guest capabilities instead of running them
This commit is contained in:
Brian Cain 2020-05-11 08:45:01 -07:00 committed by GitHub
commit 0556d21f98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,9 +36,10 @@ describe VagrantPlugins::DockerProvisioner::Installer do
end
it "installs docker if not present" do
expect(communicator).to receive(:test).with(/docker/, {:sudo=>true}).and_return(false).at_least(:twice)
# Will execute sudo commands to install
expect(communicator).to receive(:sudo).at_least(:once)
allow(machine).to receive_message_chain(:guest, :capability?).with(:docker_installed).and_return(true)
allow(machine).to receive_message_chain(:guest, :capability).with(:docker_install).and_return(false)
allow(machine).to receive_message_chain(:guest, :capability).with(:docker_installed).and_return(false)
# Expect to raise error since we are mocking out the test for docker install to return false
expect {subject.ensure_installed()}.to raise_error(VagrantPlugins::DockerProvisioner::DockerError)
end