"Fossies" - the Fresh Open Source Software Archive

Member "vagrant-2.2.14/test/unit/plugins/synced_folders/nfs/action_cleanup_test.rb" (20 Nov 2020, 1387 Bytes) of package /linux/misc/vagrant-2.2.14.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 require_relative "../../../base"
    2 
    3 require Vagrant.source_root.join("plugins/synced_folders/nfs/action_cleanup")
    4 
    5 describe VagrantPlugins::SyncedFolderNFS::ActionCleanup do
    6   include_context "unit"
    7 
    8   let(:iso_env) do
    9     # We have to create a Vagrantfile so there is a root path
   10     env = isolated_environment
   11     env.vagrantfile("")
   12     env.create_vagrant_env
   13   end
   14 
   15   let(:host)    { double("host") }
   16   let(:machine) { iso_env.machine(iso_env.machine_names[0], :dummy) }
   17 
   18   let(:app) { lambda {} }
   19   let(:env) { {
   20     machine: machine,
   21   } }
   22 
   23   subject { described_class.new(app, env) }
   24 
   25   before do
   26     allow(machine.env).to receive(:host).and_return(host)
   27   end
   28 
   29   it "does nothing if there are no valid IDs" do
   30     expect(app).to receive(:call).with(env)
   31     subject.call(env)
   32   end
   33 
   34   it "does nothing if the host doesn't support pruning NFS" do
   35     allow(host).to receive(:capability?).with(:nfs_prune).and_return(false)
   36     expect(host).to receive(:capability).never
   37     expect(app).to receive(:call).with(env)
   38 
   39     subject.call(env)
   40   end
   41 
   42   it "prunes the NFS entries if valid IDs are given" do
   43     env[:nfs_valid_ids] = [1,2,3]
   44 
   45     allow(host).to receive(:capability?).with(:nfs_prune).and_return(true)
   46     expect(host).to receive(:capability).with(:nfs_prune, machine.ui, [1,2,3]).ordered
   47     expect(app).to receive(:call).with(env).ordered
   48 
   49     subject.call(env)
   50   end
   51 end