Stub machine index proto mapper for environment test

This commit is contained in:
sophia 2022-04-05 12:43:06 -05:00 committed by Paul Hinze
parent 2044ec68d0
commit 3e641fbe6b
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 9 additions and 0 deletions

View File

@ -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__)

View File

@ -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)