Add tests for synced folder collections

This commit is contained in:
sophia 2020-08-19 17:05:39 -05:00
parent 56fa014af8
commit 943047d003
2 changed files with 50 additions and 2 deletions

View File

@ -29,14 +29,16 @@ module Vagrant
c = lambda do |h|
h.keys.each do |k|
if h[k].is_a?(Hash)
h[k] = c.call(h[k].to_h)
h[k] = c.call(h[k].to_h.clone)
end
end
h
end
h = c.call(super)
h.values.each do |f|
f.delete(:plugin)
f.values.each do |g|
g.delete(:plugin)
end
end
h
end

View File

@ -0,0 +1,46 @@
require File.expand_path("../../../../base", __FILE__)
describe Vagrant::Plugin::V2::SyncedFolder::Collection do
include_context "unit"
let(:folders) { described_class[
:nfs=>
{"/other"=>
{:type=>:nfs, :guestpath=>"/other", :hostpath=>"/other", :disabled=>false, :__vagrantfile=>true, plugin:"someclass"},
"/tests"=>
{:type=>:nfs, :guestpath=>"/tests", :hostpath=>"/tests", :disabled=>false, :__vagrantfile=>true, plugin:"someclass"}},
:virtualbox=>
{"/vagrant"=>
{:guestpath=>"/vagrant", :hostpath=>"/vagrant", :disabled=>false, :__vagrantfile=>true, plugin:"someotherclass"}}
]}
describe "#types" do
it "gets all the types of synced folders" do
expect(folders.types).to eq([:nfs, :virtualbox])
end
end
describe "#type" do
it "returns the plugin for a type" do
expect(folders.type(:nfs)).to eq("someclass")
expect(folders.type(:virtualbox)).to eq("someotherclass")
end
end
describe "to_h" do
it "removed plugin key" do
original_folders = folders
folders_h = folders.to_h
folders_h.values.each do |v|
v.values.each do |w|
expect(w).not_to include(:plugin)
end
end
original_folders.values.each do |v|
v.values.each do |w|
expect(w).to include(:plugin)
end
end
end
end
end