r10k 3.11.0 → 3.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.mkd +9 -0
  3. data/doc/dynamic-environments/configuration.mkd +7 -3
  4. data/doc/dynamic-environments/usage.mkd +26 -0
  5. data/doc/puppetfile.mkd +3 -4
  6. data/integration/tests/basic_functionality/basic_deployment.rb +176 -0
  7. data/lib/r10k/action/deploy/environment.rb +8 -1
  8. data/lib/r10k/action/deploy/module.rb +11 -6
  9. data/lib/r10k/action/puppetfile/check.rb +7 -5
  10. data/lib/r10k/action/puppetfile/install.rb +22 -16
  11. data/lib/r10k/action/puppetfile/purge.rb +12 -9
  12. data/lib/r10k/cli/deploy.rb +1 -0
  13. data/lib/r10k/cli/puppetfile.rb +0 -1
  14. data/lib/r10k/content_synchronizer.rb +16 -4
  15. data/lib/r10k/environment/base.rb +64 -11
  16. data/lib/r10k/environment/with_modules.rb +6 -10
  17. data/lib/r10k/git/stateful_repository.rb +7 -0
  18. data/lib/r10k/initializers.rb +1 -7
  19. data/lib/r10k/module/base.rb +5 -1
  20. data/lib/r10k/module/definition.rb +64 -0
  21. data/lib/r10k/module/forge.rb +10 -2
  22. data/lib/r10k/module/git.rb +22 -1
  23. data/lib/r10k/module/local.rb +2 -3
  24. data/lib/r10k/module/svn.rb +10 -0
  25. data/lib/r10k/module.rb +20 -2
  26. data/lib/r10k/module_loader/puppetfile/dsl.rb +8 -3
  27. data/lib/r10k/module_loader/puppetfile.rb +95 -29
  28. data/lib/r10k/puppetfile.rb +1 -2
  29. data/lib/r10k/settings.rb +11 -0
  30. data/lib/r10k/version.rb +1 -1
  31. data/locales/r10k.pot +75 -47
  32. data/spec/fixtures/unit/puppetfile/forge-override/Puppetfile +8 -0
  33. data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile +9 -0
  34. data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile.new +9 -0
  35. data/spec/r10k-mocks/mock_env.rb +3 -0
  36. data/spec/r10k-mocks/mock_source.rb +7 -3
  37. data/spec/unit/action/deploy/environment_spec.rb +80 -30
  38. data/spec/unit/action/deploy/module_spec.rb +50 -62
  39. data/spec/unit/action/puppetfile/check_spec.rb +17 -5
  40. data/spec/unit/action/puppetfile/install_spec.rb +42 -36
  41. data/spec/unit/action/puppetfile/purge_spec.rb +15 -17
  42. data/spec/unit/action/runner_spec.rb +0 -8
  43. data/spec/unit/environment/base_spec.rb +30 -17
  44. data/spec/unit/environment/git_spec.rb +2 -2
  45. data/spec/unit/environment/svn_spec.rb +4 -3
  46. data/spec/unit/environment/with_modules_spec.rb +2 -1
  47. data/spec/unit/module/base_spec.rb +8 -8
  48. data/spec/unit/module/forge_spec.rb +32 -4
  49. data/spec/unit/module/git_spec.rb +51 -10
  50. data/spec/unit/module/svn_spec.rb +18 -6
  51. data/spec/unit/module_loader/puppetfile_spec.rb +90 -30
  52. data/spec/unit/puppetfile_spec.rb +2 -2
  53. data/spec/unit/settings_spec.rb +25 -2
  54. metadata +7 -2
@@ -10,15 +10,41 @@ describe R10K::Module::Git do
10
10
  allow(R10K::Git::StatefulRepository).to receive(:new).and_return(mock_repo)
11
11
  end
12
12
 
13
+
14
+ describe "statically determined version support" do
15
+ it 'returns a given commit' do
16
+ static_version = described_class.statically_defined_version('branan/eight_hundred', { git: 'my/remote', commit: '123adf' })
17
+ expect(static_version).to eq('123adf')
18
+ end
19
+
20
+ it 'returns a given tag' do
21
+ static_version = described_class.statically_defined_version('branan/eight_hundred', { git: 'my/remote', tag: 'v1.2.3' })
22
+ expect(static_version).to eq('v1.2.3')
23
+ end
24
+
25
+ it 'returns a ref if it looks like a full commit sha' do
26
+ static_version = described_class.statically_defined_version('branan/eight_hundred', { git: 'my/remote', ref: '1234567890abcdef1234567890abcdef12345678' })
27
+ expect(static_version).to eq('1234567890abcdef1234567890abcdef12345678')
28
+ end
29
+
30
+ it 'returns nil for any non-sha-like ref' do
31
+ static_version = described_class.statically_defined_version('branan/eight_hundred', { git: 'my/remote', ref: 'refs/heads/main' })
32
+ expect(static_version).to eq(nil)
33
+ end
34
+
35
+ it 'returns nil for branches' do
36
+ static_version = described_class.statically_defined_version('branan/eight_hundred', { git: 'my/remote', branch: 'main' })
37
+ expect(static_version).to eq(nil)
38
+ end
39
+ end
40
+
13
41
  describe "setting the owner and name" do
14
42
  describe "with a title of 'branan/eight_hundred'" do
15
43
  subject do
16
44
  described_class.new(
17
45
  'branan/eight_hundred',
18
46
  '/moduledir',
19
- {
20
- :git => 'git://git-server.site/branan/puppet-eight_hundred',
21
- }
47
+ { :git => 'git://git-server.site/branan/puppet-eight_hundred' }
22
48
  )
23
49
  end
24
50
 
@@ -40,9 +66,7 @@ describe R10K::Module::Git do
40
66
  described_class.new(
41
67
  'eight_hundred',
42
68
  '/moduledir',
43
- {
44
- :git => 'git://git-server.site/branan/puppet-eight_hundred',
45
- }
69
+ { :git => 'git://git-server.site/branan/puppet-eight_hundred' }
46
70
  )
47
71
  end
48
72
 
@@ -97,13 +121,32 @@ describe R10K::Module::Git do
97
121
  let(:spec_path) { dirname + module_name + 'spec' }
98
122
  subject { described_class.new(title, dirname, {}) }
99
123
 
124
+ before(:each) do
125
+ allow(mock_repo).to receive(:resolve).with('master').and_return('abc123')
126
+ end
127
+
100
128
  it 'defaults to keeping the spec dir' do
101
129
  FileUtils.mkdir_p(spec_path)
102
- allow(mock_repo).to receive(:resolve).with('master').and_return('abc123')
103
130
  allow(mock_repo).to receive(:sync)
104
131
  subject.sync
105
132
  expect(Dir.exist?(spec_path)).to eq true
106
133
  end
134
+
135
+ it 'returns true if repo was updated' do
136
+ expect(mock_repo).to receive(:sync).and_return(true)
137
+ expect(subject.sync).to be true
138
+ end
139
+
140
+ it 'returns false if repo was not updated (in-sync)' do
141
+ expect(mock_repo).to receive(:sync).and_return(false)
142
+ expect(subject.sync).to be false
143
+ end
144
+
145
+ it 'returns false if `should_sync?` is false' do
146
+ # modules do not sync if they are not requested
147
+ mod = described_class.new(title, dirname, { overrides: { modules: { requested_modules: ['other_mod'] } } })
148
+ expect(mod.sync).to be false
149
+ end
107
150
  end
108
151
 
109
152
  describe "determining the status" do
@@ -111,9 +154,7 @@ describe R10K::Module::Git do
111
154
  described_class.new(
112
155
  'boolean',
113
156
  '/moduledir',
114
- {
115
- :git => 'git://git.example.com/adrienthebo/puppet-boolean'
116
- }
157
+ { :git => 'git://git.example.com/adrienthebo/puppet-boolean' }
117
158
  )
118
159
  end
119
160
 
@@ -6,6 +6,13 @@ describe R10K::Module::SVN do
6
6
 
7
7
  include_context 'fail on execution'
8
8
 
9
+ describe "statically determined version support" do
10
+ it 'is unsupported by svn backed modules' do
11
+ static_version = described_class.statically_defined_version('branan/eight_hundred', { svn: 'my/remote', revision: '123adf' })
12
+ expect(static_version).to eq(nil)
13
+ end
14
+ end
15
+
9
16
  describe "determining it implements a Puppetfile mod" do
10
17
  it "implements mods with the :svn hash key" do
11
18
  implements = described_class.implement?('r10k-fixture-repo', :svn => 'https://github.com/adrienthebo/r10k-fixture-repo')
@@ -128,7 +135,6 @@ describe R10K::Module::SVN do
128
135
  subject { described_class.new(title, dirname, {}) }
129
136
 
130
137
  it 'is kept by default' do
131
-
132
138
  FileUtils.mkdir_p(spec_path)
133
139
  expect(subject).to receive(:status).and_return(:absent)
134
140
  expect(subject).to receive(:install).and_return(nil)
@@ -150,7 +156,7 @@ describe R10K::Module::SVN do
150
156
 
151
157
  it "installs the SVN module" do
152
158
  expect(subject).to receive(:install)
153
- subject.sync
159
+ expect(subject.sync).to be true
154
160
  end
155
161
  end
156
162
 
@@ -160,14 +166,14 @@ describe R10K::Module::SVN do
160
166
  it "reinstalls the module" do
161
167
  expect(subject).to receive(:reinstall)
162
168
 
163
- subject.sync
169
+ expect(subject.sync).to be true
164
170
  end
165
171
 
166
172
  it "removes the existing directory" do
167
173
  expect(subject.path).to receive(:rmtree)
168
174
  allow(subject).to receive(:install)
169
175
 
170
- subject.sync
176
+ expect(subject.sync).to be true
171
177
  end
172
178
  end
173
179
 
@@ -177,7 +183,7 @@ describe R10K::Module::SVN do
177
183
  it "upgrades the repository" do
178
184
  expect(subject).to receive(:update)
179
185
 
180
- subject.sync
186
+ expect(subject.sync).to be true
181
187
  end
182
188
  end
183
189
 
@@ -189,8 +195,14 @@ describe R10K::Module::SVN do
189
195
  expect(subject).to receive(:reinstall).never
190
196
  expect(subject).to receive(:update).never
191
197
 
192
- subject.sync
198
+ expect(subject.sync).to be false
193
199
  end
194
200
  end
201
+
202
+ it 'and `should_sync?` is false' do
203
+ # modules do not sync if they are not requested
204
+ mod = described_class.new('my_mod', '/path/to/mod', { overrides: { modules: { requested_modules: ['other_mod'] } } })
205
+ expect(mod.sync).to be false
206
+ end
195
207
  end
196
208
  end
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'r10k/module_loader/puppetfile'
3
+ require 'tmpdir'
3
4
 
4
5
  describe R10K::ModuleLoader::Puppetfile do
5
6
  describe 'initial parameters' do
@@ -7,7 +8,6 @@ describe R10K::ModuleLoader::Puppetfile do
7
8
  let(:options) do
8
9
  {
9
10
  basedir: '/test/basedir/env',
10
- forge: 'localforge.internal.corp',
11
11
  overrides: { modules: { deploy_modules: true } },
12
12
  environment: R10K::Environment::Git.new('env',
13
13
  '/test/basedir/',
@@ -47,10 +47,6 @@ describe R10K::ModuleLoader::Puppetfile do
47
47
  end
48
48
  end
49
49
 
50
- it 'the forge' do
51
- expect(subject.instance_variable_get(:@forge)).to eq('localforge.internal.corp')
52
- end
53
-
54
50
  it 'the overrides' do
55
51
  expect(subject.instance_variable_get(:@overrides)).to eq({ modules: { deploy_modules: true }})
56
52
  end
@@ -71,10 +67,6 @@ describe R10K::ModuleLoader::Puppetfile do
71
67
  expect(subject.instance_variable_get(:@puppetfile_path)).to eq('/test/basedir/Puppetfile')
72
68
  end
73
69
 
74
- it 'uses the public forge' do
75
- expect(subject.instance_variable_get(:@forge)).to eq('forgeapi.puppetlabs.com')
76
- end
77
-
78
70
  it 'creates an empty overrides' do
79
71
  expect(subject.instance_variable_get(:@overrides)).to eq({})
80
72
  end
@@ -91,14 +83,14 @@ describe R10K::ModuleLoader::Puppetfile do
91
83
  subject { R10K::ModuleLoader::Puppetfile.new(basedir: basedir) }
92
84
 
93
85
  it 'should transform Forge modules with a string arg to have a version key' do
94
- expect(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, hash_including(version: '1.2.3'), anything).and_call_original
86
+ expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', subject.moduledir, hash_including(version: '1.2.3'), anything).and_call_original
95
87
 
96
88
  expect { subject.add_module('puppet/test_module', '1.2.3') }.to change { subject.modules }
97
89
  expect(subject.modules.collect(&:name)).to include('test_module')
98
90
  end
99
91
 
100
92
  it 'should not accept Forge modules with a version comparison' do
101
- expect(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, hash_including(version: '< 1.2.0'), anything).and_call_original
93
+ expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', subject.moduledir, hash_including(version: '< 1.2.0'), anything).and_call_original
102
94
 
103
95
  expect {
104
96
  subject.add_module('puppet/test_module', '< 1.2.0')
@@ -122,7 +114,7 @@ describe R10K::ModuleLoader::Puppetfile do
122
114
  it 'should accept non-Forge modules with a hash arg' do
123
115
  module_opts = { git: 'git@example.com:puppet/test_module.git' }
124
116
 
125
- expect(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, module_opts, anything).and_call_original
117
+ expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', subject.moduledir, module_opts, anything).and_call_original
126
118
 
127
119
  expect { subject.add_module('puppet/test_module', module_opts) }.to change { subject.modules }
128
120
  expect(subject.modules.collect(&:name)).to include('test_module')
@@ -134,7 +126,7 @@ describe R10K::ModuleLoader::Puppetfile do
134
126
  git: 'git@example.com:puppet/test_module.git',
135
127
  }
136
128
 
137
- expect(R10K::Module).to receive(:new).with('puppet/test_module', File.join(basedir, 'vendor'), module_opts, anything).and_call_original
129
+ expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', File.join(basedir, 'vendor'), module_opts, anything).and_call_original
138
130
 
139
131
  expect { subject.add_module('puppet/test_module', module_opts) }.to change { subject.modules }
140
132
  expect(subject.modules.collect(&:name)).to include('test_module')
@@ -148,7 +140,7 @@ describe R10K::ModuleLoader::Puppetfile do
148
140
  git: 'git@example.com:puppet/test_module.git',
149
141
  }
150
142
 
151
- expect(R10K::Module).to receive(:new).with('puppet/test_module', install_path, module_opts, anything).and_call_original
143
+ expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', install_path, module_opts, anything).and_call_original
152
144
 
153
145
  expect { subject.add_module('puppet/test_module', module_opts) }.to change { subject.modules }
154
146
  expect(subject.modules.collect(&:name)).to include('test_module')
@@ -179,7 +171,7 @@ describe R10K::ModuleLoader::Puppetfile do
179
171
  allow(env).to receive(:'module_conflicts?').with(mod).and_return(true)
180
172
  allow(mod).to receive(:spec_deletable=)
181
173
 
182
- expect(R10K::Module).to receive(:new).with('conflict', anything, anything, anything).and_return(mod)
174
+ expect(R10K::Module).to receive(:from_metadata).with('conflict', anything, anything, anything).and_return(mod)
183
175
  expect { loader.add_module('conflict', {}) }.not_to change { loader.modules }
184
176
  end
185
177
  end
@@ -214,9 +206,9 @@ describe R10K::ModuleLoader::Puppetfile do
214
206
  end
215
207
 
216
208
  it 'returns an array of paths that #purge! will operate within' do
217
- expect(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, hash_including(version: '1.2.3'), anything).and_call_original
209
+ expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', subject.moduledir, hash_including(version: '1.2.3'), anything).and_call_original
218
210
  subject.add_module('puppet/test_module', '1.2.3')
219
- subject.load
211
+ subject.load!
220
212
 
221
213
  expect(subject.modules.length).to be 1
222
214
  expect(subject.managed_directories).to match_array([subject.moduledir])
@@ -226,9 +218,9 @@ describe R10K::ModuleLoader::Puppetfile do
226
218
  it "basedir isn't in the list of paths to purge" do
227
219
  module_opts = { install_path: '', git: 'git@example.com:puppet/test_module.git' }
228
220
 
229
- expect(R10K::Module).to receive(:new).with('puppet/test_module', basedir, module_opts, anything).and_call_original
221
+ expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', basedir, module_opts, anything).and_call_original
230
222
  subject.add_module('puppet/test_module', module_opts)
231
- subject.load
223
+ subject.load!
232
224
 
233
225
  expect(subject.modules.length).to be 1
234
226
  expect(subject.managed_directories).to be_empty
@@ -249,7 +241,7 @@ describe R10K::ModuleLoader::Puppetfile do
249
241
  @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'invalid-syntax')
250
242
  pf_path = File.join(@path, 'Puppetfile')
251
243
  expect {
252
- subject.load
244
+ subject.load!
253
245
  }.to raise_error do |e|
254
246
  expect_wrapped_error(e, pf_path, SyntaxError)
255
247
  end
@@ -259,7 +251,7 @@ describe R10K::ModuleLoader::Puppetfile do
259
251
  @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'load-error')
260
252
  pf_path = File.join(@path, 'Puppetfile')
261
253
  expect {
262
- subject.load
254
+ subject.load!
263
255
  }.to raise_error do |e|
264
256
  expect_wrapped_error(e, pf_path, LoadError)
265
257
  end
@@ -269,17 +261,38 @@ describe R10K::ModuleLoader::Puppetfile do
269
261
  @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'argument-error')
270
262
  pf_path = File.join(@path, 'Puppetfile')
271
263
  expect {
272
- subject.load
264
+ subject.load!
273
265
  }.to raise_error do |e|
274
266
  expect_wrapped_error(e, pf_path, ArgumentError)
275
267
  end
276
268
  end
277
269
 
270
+ describe 'forge declaration' do
271
+ before(:each) do
272
+ PuppetForge.host = ""
273
+ end
274
+
275
+ it 'is respected if `allow_puppetfile_override` is true' do
276
+ @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'forge-override')
277
+ puppetfile = R10K::ModuleLoader::Puppetfile.new(basedir: @path, overrides: { forge: { allow_puppetfile_override: true } })
278
+ puppetfile.load!
279
+ expect(PuppetForge.host).to eq("my.custom.forge.com/")
280
+ end
281
+
282
+ it 'is ignored if `allow_puppetfile_override` is false' do
283
+ @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'forge-override')
284
+ puppetfile = R10K::ModuleLoader::Puppetfile.new(basedir: @path, overrides: { forge: { allow_puppetfile_override: false } })
285
+ expect(PuppetForge).not_to receive(:host=).with("my.custom.forge.com")
286
+ puppetfile.load!
287
+ expect(PuppetForge.host).to eq("/")
288
+ end
289
+ end
290
+
278
291
  it 'rejects Puppetfiles with duplicate module names' do
279
292
  @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'duplicate-module-error')
280
293
  pf_path = File.join(@path, 'Puppetfile')
281
294
  expect {
282
- subject.load
295
+ subject.load!
283
296
  }.to raise_error(R10K::Error, /Puppetfiles cannot contain duplicate module names/i)
284
297
  end
285
298
 
@@ -287,7 +300,7 @@ describe R10K::ModuleLoader::Puppetfile do
287
300
  @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'name-error')
288
301
  pf_path = File.join(@path, 'Puppetfile')
289
302
  expect {
290
- subject.load
303
+ subject.load!
291
304
  }.to raise_error do |e|
292
305
  expect_wrapped_error(e, pf_path, NameError)
293
306
  end
@@ -296,21 +309,21 @@ describe R10K::ModuleLoader::Puppetfile do
296
309
  it 'accepts a forge module with a version' do
297
310
  @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
298
311
  pf_path = File.join(@path, 'Puppetfile')
299
- expect { subject.load }.not_to raise_error
312
+ expect { subject.load! }.not_to raise_error
300
313
  end
301
314
 
302
315
  describe 'setting a custom moduledir' do
303
316
  it 'allows setting an absolute moduledir' do
304
317
  @path = '/fake/basedir'
305
318
  allow(subject).to receive(:puppetfile_content).and_return('moduledir "/fake/moduledir"')
306
- subject.load
319
+ subject.load!
307
320
  expect(subject.instance_variable_get(:@moduledir)).to eq('/fake/moduledir')
308
321
  end
309
322
 
310
323
  it 'roots relative moduledirs in the basedir' do
311
324
  @path = '/fake/basedir'
312
325
  allow(subject).to receive(:puppetfile_content).and_return('moduledir "my/moduledir"')
313
- subject.load
326
+ subject.load!
314
327
  expect(subject.instance_variable_get(:@moduledir)).to eq(File.join(@path, 'my/moduledir'))
315
328
  end
316
329
  end
@@ -318,13 +331,13 @@ describe R10K::ModuleLoader::Puppetfile do
318
331
  it 'accepts a forge module without a version' do
319
332
  @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-without-version')
320
333
  pf_path = File.join(@path, 'Puppetfile')
321
- expect { subject.load }.not_to raise_error
334
+ expect { subject.load! }.not_to raise_error
322
335
  end
323
336
 
324
337
  it 'creates a git module and applies the default branch specified in the Puppetfile' do
325
338
  @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'default-branch-override')
326
339
  pf_path = File.join(@path, 'Puppetfile')
327
- expect { subject.load }.not_to raise_error
340
+ expect { subject.load! }.not_to raise_error
328
341
  git_module = subject.modules[0]
329
342
  expect(git_module.default_ref).to eq 'here_lies_the_default_branch'
330
343
  end
@@ -334,10 +347,57 @@ describe R10K::ModuleLoader::Puppetfile do
334
347
  pf_path = File.join(@path, 'Puppetfile')
335
348
  default_branch_override = 'default_branch_override_name'
336
349
  subject.default_branch_override = default_branch_override
337
- expect { subject.load }.not_to raise_error
350
+ expect { subject.load! }.not_to raise_error
338
351
  git_module = subject.modules[0]
339
352
  expect(git_module.default_override_ref).to eq default_branch_override
340
353
  expect(git_module.default_ref).to eq 'here_lies_the_default_branch'
341
354
  end
355
+
356
+ describe 'using module metadata' do
357
+ it 'properly loads module metadata' do
358
+ @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'various-modules')
359
+ metadata = subject.load_metadata[:modules].map { |mod| [ mod.name, mod.version ] }.to_h
360
+ expect(metadata['apt']).to eq('2.1.1')
361
+ expect(metadata['stdlib']).to eq(nil)
362
+ expect(metadata['concat']).to eq(nil)
363
+ expect(metadata['rpm']).to eq('2.1.1-pre1')
364
+ expect(metadata['foo']).to eq(nil)
365
+ expect(metadata['bar']).to eq('v1.2.3')
366
+ expect(metadata['baz']).to eq('123abc456')
367
+ expect(metadata['fizz']).to eq('1234567890abcdef1234567890abcdef12345678')
368
+ expect(metadata['buzz']).to eq(nil)
369
+ end
370
+
371
+ it 'does not load module implementations for static versioned' do
372
+ @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'various-modules')
373
+ subject.load_metadata
374
+ modules = subject.load[:modules].map { |mod| [ mod.name, mod ] }.to_h
375
+ expect(modules['apt']).to be_a_kind_of(R10K::Module::Definition)
376
+ expect(modules['stdlib']).to be_a_kind_of(R10K::Module::Forge)
377
+ expect(modules['concat']).to be_a_kind_of(R10K::Module::Forge)
378
+ expect(modules['rpm']).to be_a_kind_of(R10K::Module::Definition)
379
+ expect(modules['foo']).to be_a_kind_of(R10K::Module::Git)
380
+ expect(modules['bar']).to be_a_kind_of(R10K::Module::Definition)
381
+ expect(modules['baz']).to be_a_kind_of(R10K::Module::Definition)
382
+ expect(modules['fizz']).to be_a_kind_of(R10K::Module::Definition)
383
+ expect(modules['buzz']).to be_a_kind_of(R10K::Module::Git)
384
+ end
385
+
386
+ it 'loads module implementations whose static versions are different' do
387
+ fixture_path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'various-modules')
388
+ @path = Dir.mktmpdir
389
+ unsynced_pf_path = File.join(fixture_path, 'Puppetfile')
390
+ FileUtils.cp(unsynced_pf_path, @path)
391
+
392
+ subject.load_metadata
393
+
394
+ synced_pf_path = File.join(fixture_path, 'Puppetfile.new')
395
+ FileUtils.cp(synced_pf_path, File.join(@path, 'Puppetfile'))
396
+
397
+ modules = subject.load[:modules].map { |mod| [ mod.name, mod ] }.to_h
398
+
399
+ expect(modules['apt']).to be_a_kind_of(R10K::Module::Forge)
400
+ end
401
+ end
342
402
  end
343
403
  end
@@ -114,7 +114,7 @@ describe R10K::Puppetfile do
114
114
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
115
115
  subject = described_class.new(path, {})
116
116
 
117
- expect(subject.loader).to receive(:load).and_call_original.once
117
+ expect(subject.loader).to receive(:load!).and_call_original.once
118
118
 
119
119
  loaded_content1 = subject.load
120
120
  expect(subject.loaded?).to be true
@@ -273,7 +273,7 @@ describe R10K::Puppetfile do
273
273
  expect(subject).to receive(:modules).and_return([mod1, mod2])
274
274
 
275
275
  expect(Thread).to receive(:new).exactly(pool_size).and_call_original
276
- expect(Queue).to receive(:new).and_call_original
276
+ expect(Queue).to receive(:new).and_call_original.twice
277
277
 
278
278
  subject.accept(visitor)
279
279
  end