From 9e9f3d8f2cc9b9c0013997c0e86518a52a05f267 Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Mon, 22 May 2023 11:06:13 +0200 Subject: [PATCH] Update unit test for synced folders It's related to the new class for macvm guests: https://github.com/Parallels/vagrant-parallels/pull/448 --- test/unit/synced_folder_macvm_test.rb | 43 +++++++++++++++++++++++++++ test/unit/synced_folder_test.rb | 6 ++++ 2 files changed, 49 insertions(+) create mode 100644 test/unit/synced_folder_macvm_test.rb diff --git a/test/unit/synced_folder_macvm_test.rb b/test/unit/synced_folder_macvm_test.rb new file mode 100644 index 00000000..fc964d47 --- /dev/null +++ b/test/unit/synced_folder_macvm_test.rb @@ -0,0 +1,43 @@ +require 'vagrant' +require_relative 'base' + +require VagrantPlugins::Parallels.source_root.join('lib/vagrant-parallels/config') +require VagrantPlugins::Parallels.source_root.join('lib/vagrant-parallels/synced_folder_macvm') + +describe VagrantPlugins::Parallels::SyncedFolderMacVM do + let(:machine) do + double('machine').tap do |m| + allow(m).to receive_messages(provider_name: :parallels) + allow(VagrantPlugins::Parallels::Util::Common).to receive(:is_macvm).with(m).and_return(true) + end + end + + subject { described_class.new } + + describe 'usable' do + it 'should be with parallels provider' do + allow(machine).to receive_messages(provider_name: :parallels) + expect(subject).to be_usable(machine) + end + + it 'should not be with another provider' do + allow(machine).to receive_messages(provider_name: :virtualbox) + expect(subject).not_to be_usable(machine) + end + + it 'should be with macvm guest' do + allow(VagrantPlugins::Parallels::Util::Common).to receive(:is_macvm).with(machine).and_return(true) + expect(subject).to be_usable(machine) + end + end + + describe 'prepare' do + let(:driver) { double('driver') } + + before do + allow(machine).to receive_messages(driver: driver) + end + + it 'should share the folders' + end +end diff --git a/test/unit/synced_folder_test.rb b/test/unit/synced_folder_test.rb index be752c11..1635a0d4 100644 --- a/test/unit/synced_folder_test.rb +++ b/test/unit/synced_folder_test.rb @@ -9,6 +9,7 @@ double('machine').tap do |m| allow(m).to receive_messages(provider_config: VagrantPlugins::Parallels::Config.new) allow(m).to receive_messages(provider_name: :parallels) + allow(VagrantPlugins::Parallels::Util::Common).to receive(:is_macvm).with(m).and_return(false) end end @@ -29,6 +30,11 @@ expect(subject).not_to be_usable(machine) end + it 'should not be with macvm guest' do + allow(VagrantPlugins::Parallels::Util::Common).to receive(:is_macvm).with(machine).and_return(true) + expect(subject).not_to be_usable(machine) + end + it 'should not be usable if not functional psf' do machine.provider_config.functional_psf = false expect(subject).to_not be_usable(machine)