beaker-puppet 1.13.0 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6082215f1011bfa1a62afb5863e4d207477fe23
4
- data.tar.gz: 5f43469bc7a545f5bbda83d78b5425120723e1f3
3
+ metadata.gz: 6454b6b6a2bb05e3b0ae6ba82f8238cccb73bfce
4
+ data.tar.gz: 958e42dc43c40e04f5aa8c69441c706d0bad6563
5
5
  SHA512:
6
- metadata.gz: f0023d9eb1b559504e4994f7b233d3d8e80f63618f865a0f6c1d0358c9dc08ee7596cd6f852f16c8ce8c2d2c9f81b5231822c6727a84664fa5cce8395440fc1e
7
- data.tar.gz: 9a49f5b8afbe19505f5002fcfa9409f979fc6da8a970f8dc442a06e2c085772142786d9fd43d91ebf8164eccf57513d265497340b6fcd4e486d3f5949dfefdf9
6
+ metadata.gz: 183642058a37616a50c16d42f8abb88589bc04ca69ee21da363581bc02510cb34abb118620228ad27215de8c31b2924421a796a09ce9cab2a30427bbbc7d1fd8
7
+ data.tar.gz: 13adb1d9345353a944582d5572e28def90d9c9a97f092780627f1ba75e212b2470cb4c82240d3832b53fc01b3e35221ace42d2b015cd75e6c375b5005cdf604c
@@ -118,9 +118,8 @@ module Beaker
118
118
  :ignore_list => PUPPET_MODULE_INSTALL_IGNORE}.merge(opts)
119
119
 
120
120
  ignore_list = build_ignore_list(opts)
121
- target_module_dir = on( host, "echo #{opts[:target_module_path]}" ).stdout.chomp
121
+ target_module_dir = get_target_module_path(host, opts[:target_module_path])
122
122
  source_path = File.expand_path( opts[:source] )
123
- source_dir = File.dirname(source_path)
124
123
  source_name = File.basename(source_path)
125
124
  if opts.has_key?(:module_name)
126
125
  module_name = opts[:module_name]
@@ -157,6 +156,16 @@ module Beaker
157
156
  end
158
157
  alias :copy_root_module_to :copy_module_to
159
158
 
159
+ def get_target_module_path(host, path=nil)
160
+ if path
161
+ on( host, "echo #{path}" ).stdout.chomp
162
+ else
163
+ path = host.puppet['basemodulepath'].split(':').first
164
+ raise ArgumentError, 'Unable to find target module path to copy to' unless path
165
+ path
166
+ end
167
+ end
168
+
160
169
  #Recursive method for finding the module root
161
170
  # Assumes that a Modulefile exists
162
171
  # @param [String] possible_module_directory
@@ -1,3 +1,3 @@
1
1
  module BeakerPuppet
2
- VERSION = '1.13.0'
2
+ VERSION = '1.14.0'
3
3
  end
@@ -237,6 +237,61 @@ describe ClassMixedWithDSLInstallUtils do
237
237
  end
238
238
  end
239
239
 
240
+ describe 'get_target_module_path' do
241
+ let(:host) do
242
+ host = make_host("echo '/explicit/modulepath'", {stdout: "/explicit/modulepath\n"})
243
+ allow(host).to receive(:puppet).and_return(puppet)
244
+ host
245
+ end
246
+ let(:puppet) do
247
+ puppet = instance_double('PuppetConfigReader')
248
+ allow(puppet).to receive(:[]).with('basemodulepath').and_return(basemodulepath)
249
+ puppet
250
+ end
251
+
252
+ context 'no modulepath' do
253
+ let(:basemodulepath) { '' }
254
+
255
+ it 'should prefer the explicit path' do
256
+ expect(subject.get_target_module_path(host, '/explicit/modulepath')).to eq('/explicit/modulepath')
257
+ expect(puppet).not_to have_received(:[]).with('basemodulepath')
258
+ end
259
+
260
+ it 'should raise an error if no directory is found' do
261
+ expect { subject.get_target_module_path(host) }.to raise_error(ArgumentError, 'Unable to find target module path to copy to')
262
+ expect(puppet).to have_received(:[]).with('basemodulepath')
263
+ end
264
+ end
265
+
266
+ context 'single modulepath' do
267
+ let(:basemodulepath) { '/path/to/modulepath' }
268
+
269
+ it 'should prefer the explicit path' do
270
+ expect(subject.get_target_module_path(host, '/explicit/modulepath')).to eq('/explicit/modulepath')
271
+ expect(puppet).not_to have_received(:[]).with('basemodulepath')
272
+ end
273
+
274
+ it 'should fall back to autodetection' do
275
+ expect(subject.get_target_module_path(host)).to eq('/path/to/modulepath')
276
+ expect(puppet).to have_received(:[]).with('basemodulepath')
277
+ end
278
+ end
279
+
280
+ context 'multiple directories' do
281
+ let(:basemodulepath) { '/home/puppet/modules:/path/to/modulepath' }
282
+
283
+ it 'should prefer the explicit path' do
284
+ expect(subject.get_target_module_path(host, '/explicit/modulepath')).to eq('/explicit/modulepath')
285
+ expect(puppet).not_to have_received(:[]).with('basemodulepath')
286
+ end
287
+
288
+ it 'should return the first directory' do
289
+ expect(subject.get_target_module_path(host)).to eq('/home/puppet/modules')
290
+ expect(puppet).to have_received(:[]).with('basemodulepath')
291
+ end
292
+ end
293
+ end
294
+
240
295
  describe 'parse_for_modulename' do
241
296
  directory = '/testfilepath/myname-testmodule'
242
297
  it 'should return name from metadata.json' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-13 00:00:00.000000000 Z
11
+ date: 2018-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec