SHA256
1
0
forked from pool/vagrant
vagrant/0011-Fixes-11606-Mock-out-guest-capabilities-instead-of-r.patch

40 lines
1.9 KiB
Diff

From e4b3e72c9a267097e803db8b1b936523ee84ce0b Mon Sep 17 00:00:00 2001
From: Brian Cain <bcain@hashicorp.com>
Date: Mon, 11 May 2020 08:01:29 -0700
Subject: [PATCH 11/11] Fixes #11606: Mock out guest capabilities instead of
running them
This commit fixes a test that only fails on certain users machines where
Vagrant ends up trying to run real guest capabilities to test if the
docker provisioner raises an error if the provisioner install failed. It
fixes it by mocking out the expected return values for those
capabilities rather than relying on them actually running for this
specific unit test.
(cherry picked from commit 3934a26c2974a1795f25db31e98300386a71881d)
---
test/unit/plugins/provisioners/docker/installer_test.rb | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/test/unit/plugins/provisioners/docker/installer_test.rb b/test/unit/plugins/provisioners/docker/installer_test.rb
index c21654b63..e8cd8fb3f 100644
--- a/test/unit/plugins/provisioners/docker/installer_test.rb
+++ b/test/unit/plugins/provisioners/docker/installer_test.rb
@@ -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
--
2.26.2