From 3e641fbe6be3dcde73b287fb115c131111f31c49 Mon Sep 17 00:00:00 2001 From: sophia Date: Tue, 5 Apr 2022 12:43:06 -0500 Subject: [PATCH] Stub machine index proto mapper for environment test --- plugins/kernel_v2/config/vm.rb | 3 +++ test/unit/vagrant/environment_test.rb | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index b7a2e4255..b5eb61035 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -16,6 +16,9 @@ require "vagrant/protobufs/proto/protostructure_pb" require "vagrant/protobufs/proto/vagrant_plugin_sdk/plugin_pb" require "vagrant/protobufs/proto/vagrant_plugin_sdk/plugin_services_pb" +# Include mappers +require Vagrant.source_root.join("plugins/commands/serve/command").to_s + require File.expand_path("../vm_provisioner", __FILE__) require File.expand_path("../vm_subvm", __FILE__) require File.expand_path("../disk", __FILE__) diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index 3694560d6..5483457eb 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -641,6 +641,12 @@ VF it "uses a directory within the home directory by default" do klass = double("machine_index") stub_const("Vagrant::MachineIndex", klass) + # Need to stub the mappers here since the Vagrant::MachineIndex module is getting + # stubbed as a double. This is causing the mapper definition to fail on account + # of the Input to the mapper not being a module. The mapper has no impact on this + # test otherwise. + stub_mapper = Class.new {} + stub_const("VagrantPlugins::CommandServe::Mappers", stub_mapper) expect(klass).to receive(:new).with(any_args) do |path| expect(path.to_s.start_with?(subject.home_path.to_s)).to be(true)