spec/unit/puppetfile_spec.rb in r10k-3.7.0 vs spec/unit/puppetfile_spec.rb in r10k-3.8.0
- old
+ new
@@ -126,27 +126,19 @@
allow(R10K::Module).to receive(:new).with('puppet/test_module', File.join(subject.basedir, 'vendor'), module_opts, anything).and_call_original
expect { subject.add_module('puppet/test_module', module_opts) }.to raise_error(R10K::Error, /cannot manage content.*is not within/i).and not_change { subject.modules }
end
- it "groups modules by vcs cache location" do
- module_opts = { install_path: File.join(subject.basedir, 'vendor') }
- opts1 = module_opts.merge(git: 'git@example.com:puppet/test_module.git')
- opts2 = module_opts.merge(git: 'git@example.com:puppet/test_module_c.git')
- sanitized_name1 = "git@example.com-puppet-test_module.git"
- sanitized_name2 = "git@example.com-puppet-test_module_c.git"
+ it "should disable and not add modules that conflict with the environment" do
+ env = instance_double('R10K::Environment::Base')
+ mod = instance_double('R10K::Module::Base', name: 'conflict', origin: :puppetfile)
+ allow(mod).to receive(:origin=).and_return(nil)
+ allow(subject).to receive(:environment).and_return(env)
+ allow(env).to receive(:'module_conflicts?').with(mod).and_return(true)
- subject.add_module('puppet/test_module_a', opts1)
- subject.add_module('puppet/test_module_b', opts1)
- subject.add_module('puppet/test_module_c', opts2)
- subject.add_module('puppet/test_module_d', '1.2.3')
-
- mods_by_cachedir = subject.modules_by_vcs_cachedir
-
- expect(mods_by_cachedir[:none].length).to be 1
- expect(mods_by_cachedir[sanitized_name1].length).to be 2
- expect(mods_by_cachedir[sanitized_name2].length).to be 1
+ allow(R10K::Module).to receive(:new).with('test', anything, anything, anything).and_return(mod)
+ expect { subject.add_module('test', {}) }.not_to change { subject.modules }
end
end
describe "#purge_exclusions" do
let(:managed_dirs) { ['dir1', 'dir2'] }
@@ -281,11 +273,12 @@
pf_path = File.join(path, 'Puppetfile')
subject = described_class.new(path)
default_branch_override = 'default_branch_override_name'
expect { subject.load!(default_branch_override) }.not_to raise_error
git_module = subject.modules[0]
- expect(git_module.default_ref).to eq default_branch_override
+ expect(git_module.default_override_ref).to eq default_branch_override
+ expect(git_module.default_ref).to eq "here_lies_the_default_branch"
end
end
describe "accepting a visitor" do
it "passes itself to the visitor" do
@@ -300,16 +293,16 @@
expect(type).to eq :puppetfile
expect(other).to eq subject
block.call
end
- mod1 = spy('module')
+ mod1 = instance_double('R10K::Module::Base', :cachedir => :none)
+ mod2 = instance_double('R10K::Module::Base', :cachedir => :none)
expect(mod1).to receive(:accept).with(visitor)
- mod2 = spy('module')
expect(mod2).to receive(:accept).with(visitor)
+ expect(subject).to receive(:modules).and_return([mod1, mod2])
- expect(subject).to receive(:modules_by_vcs_cachedir).and_return({none: [mod1, mod2]})
subject.accept(visitor)
end
it "creates a thread pool to visit concurrently if pool_size setting is greater than one" do
pool_size = 3
@@ -321,17 +314,16 @@
expect(type).to eq :puppetfile
expect(other).to eq subject
block.call
end
- mod1 = spy('module')
+ mod1 = instance_double('R10K::Module::Base', :cachedir => :none)
+ mod2 = instance_double('R10K::Module::Base', :cachedir => :none)
expect(mod1).to receive(:accept).with(visitor)
- mod2 = spy('module')
expect(mod2).to receive(:accept).with(visitor)
+ expect(subject).to receive(:modules).and_return([mod1, mod2])
- expect(subject).to receive(:modules_by_vcs_cachedir).and_return({none: [mod1, mod2]})
-
expect(Thread).to receive(:new).exactly(pool_size).and_call_original
expect(Queue).to receive(:new).and_call_original
subject.accept(visitor)
end
@@ -342,24 +334,21 @@
expect(type).to eq :puppetfile
expect(other).to eq subject
block.call
end
- mod1 = spy('module1')
- mod2 = spy('module2')
- mod3 = spy('module3')
- mod4 = spy('module4')
- mod5 = spy('module5')
- mod6 = spy('module6')
+ m1 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/A')
+ m2 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/B')
+ m3 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/C')
+ m4 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/C')
+ m5 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/D')
+ m6 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/D')
- expect(subject).to receive(:modules_by_vcs_cachedir)
- .and_return({:none => [mod1, mod2],
- "foo-cachedir" => [mod3, mod4],
- "bar-cachedir" => [mod5, mod6]})
+ expect(subject).to receive(:modules).and_return([m1, m2, m3, m4, m5, m6])
queue = subject.modules_queue(visitor)
expect(queue.length).to be 4
queue_array = 4.times.map { queue.pop }
- expect(queue_array).to match_array([[mod1], [mod2], [mod3, mod4], [mod5, mod6]])
+ expect(queue_array).to match_array([[m1], [m2], [m3, m4], [m5, m6]])
end
end
end