From e96d60c02904294dfe322d0b4c91ce7954929bb3 Mon Sep 17 00:00:00 2001 From: sophia Date: Thu, 20 Aug 2020 09:50:00 -0500 Subject: [PATCH] Add tests for persisting shared folders --- .../action/builtin/mixin_synced_folders.rb | 1 - lib/vagrant/util/typed_hash.rb | 15 --------------- .../linux/cap/persist_mount_shared_folder_test.rb | 13 +++++++++++++ 3 files changed, 13 insertions(+), 16 deletions(-) delete mode 100644 lib/vagrant/util/typed_hash.rb diff --git a/lib/vagrant/action/builtin/mixin_synced_folders.rb b/lib/vagrant/action/builtin/mixin_synced_folders.rb index 507c5d475..870aaee9c 100644 --- a/lib/vagrant/action/builtin/mixin_synced_folders.rb +++ b/lib/vagrant/action/builtin/mixin_synced_folders.rb @@ -2,7 +2,6 @@ require "json" require "set" require 'vagrant/util/scoped_hash_override' -require 'vagrant/util/typed_hash' module Vagrant module Action diff --git a/lib/vagrant/util/typed_hash.rb b/lib/vagrant/util/typed_hash.rb deleted file mode 100644 index 5b8ebc8f4..000000000 --- a/lib/vagrant/util/typed_hash.rb +++ /dev/null @@ -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 diff --git a/test/unit/plugins/guests/linux/cap/persist_mount_shared_folder_test.rb b/test/unit/plugins/guests/linux/cap/persist_mount_shared_folder_test.rb index f7ae6b51b..aa65b38b7 100644 --- a/test/unit/plugins/guests/linux/cap/persist_mount_shared_folder_test.rb +++ b/test/unit/plugins/guests/linux/cap/persist_mount_shared_folder_test.rb @@ -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