Add tests for persisting shared folders

This commit is contained in:
sophia 2020-08-20 09:50:00 -05:00
parent 943047d003
commit e96d60c029
3 changed files with 13 additions and 16 deletions

View File

@ -2,7 +2,6 @@ require "json"
require "set"
require 'vagrant/util/scoped_hash_override'
require 'vagrant/util/typed_hash'
module Vagrant
module Action

View File

@ -1,15 +0,0 @@
module Vagrant
module Util
class TypedHash < Hash
# Types available in the Hash
attr_accessor :types
def initialize(**opts)
if opts[:types]
@types = opts[:types]
end
end
end
end
end

View File

@ -33,6 +33,7 @@ describe "VagrantPlugins::GuestLinux::Cap::PersistMountSharedFolder" do
before do
allow(machine).to receive(:communicate).and_return(comm)
allow(machine).to receive(:ssh_info).and_return(ssh_info)
allow(folder_plugin).to receive(:capability?).with(:mount_type).and_return(true)
allow(folder_plugin).to receive(:capability).with(:mount_options, any_args).
and_return(["uid=#{options_uid},gid=#{options_gid}", options_uid, options_gid])
allow(folder_plugin).to receive(:capability).with(:mount_type).and_return("vboxsf")
@ -65,5 +66,17 @@ describe "VagrantPlugins::GuestLinux::Cap::PersistMountSharedFolder" do
expect(cap).to receive(:remove_vagrant_managed_fstab)
cap.persist_mount_shared_folder(machine, nil)
end
context "folders do not support mount_type capability" do
before do
allow(folder_plugin).to receive(:capability?).with(:mount_type).and_return(false)
end
it "does not inserts folders into /etc/fstab" do
expect(cap).to receive(:remove_vagrant_managed_fstab)
expect(comm).not_to receive(:sudo).with(/echo '' >> \/etc\/fstab/)
cap.persist_mount_shared_folder(machine, folders)
end
end
end
end