vanagon 0.3.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +13 -0
  3. data/README.md +175 -0
  4. data/bin/build +33 -0
  5. data/bin/devkit +22 -0
  6. data/bin/repo +26 -0
  7. data/bin/ship +15 -0
  8. data/lib/vanagon.rb +8 -0
  9. data/lib/vanagon/common.rb +2 -0
  10. data/lib/vanagon/common/pathname.rb +87 -0
  11. data/lib/vanagon/common/user.rb +25 -0
  12. data/lib/vanagon/component.rb +157 -0
  13. data/lib/vanagon/component/dsl.rb +307 -0
  14. data/lib/vanagon/component/source.rb +66 -0
  15. data/lib/vanagon/component/source/git.rb +60 -0
  16. data/lib/vanagon/component/source/http.rb +158 -0
  17. data/lib/vanagon/driver.rb +112 -0
  18. data/lib/vanagon/engine/base.rb +82 -0
  19. data/lib/vanagon/engine/docker.rb +40 -0
  20. data/lib/vanagon/engine/local.rb +40 -0
  21. data/lib/vanagon/engine/pooler.rb +85 -0
  22. data/lib/vanagon/errors.rb +28 -0
  23. data/lib/vanagon/extensions/string.rb +11 -0
  24. data/lib/vanagon/optparse.rb +62 -0
  25. data/lib/vanagon/platform.rb +245 -0
  26. data/lib/vanagon/platform/deb.rb +71 -0
  27. data/lib/vanagon/platform/dsl.rb +293 -0
  28. data/lib/vanagon/platform/osx.rb +100 -0
  29. data/lib/vanagon/platform/rpm.rb +76 -0
  30. data/lib/vanagon/platform/rpm/wrl.rb +39 -0
  31. data/lib/vanagon/platform/solaris_10.rb +182 -0
  32. data/lib/vanagon/platform/solaris_11.rb +138 -0
  33. data/lib/vanagon/platform/swix.rb +35 -0
  34. data/lib/vanagon/project.rb +251 -0
  35. data/lib/vanagon/project/dsl.rb +218 -0
  36. data/lib/vanagon/utilities.rb +299 -0
  37. data/spec/fixures/component/invalid-test-fixture.json +3 -0
  38. data/spec/fixures/component/mcollective.service +1 -0
  39. data/spec/fixures/component/test-fixture.json +4 -0
  40. data/spec/lib/vanagon/common/pathname_spec.rb +103 -0
  41. data/spec/lib/vanagon/common/user_spec.rb +36 -0
  42. data/spec/lib/vanagon/component/dsl_spec.rb +443 -0
  43. data/spec/lib/vanagon/component/source/git_spec.rb +19 -0
  44. data/spec/lib/vanagon/component/source/http_spec.rb +43 -0
  45. data/spec/lib/vanagon/component/source_spec.rb +99 -0
  46. data/spec/lib/vanagon/component_spec.rb +22 -0
  47. data/spec/lib/vanagon/engine/base_spec.rb +40 -0
  48. data/spec/lib/vanagon/engine/docker_spec.rb +40 -0
  49. data/spec/lib/vanagon/engine/pooler_spec.rb +54 -0
  50. data/spec/lib/vanagon/platform/deb_spec.rb +60 -0
  51. data/spec/lib/vanagon/platform/dsl_spec.rb +128 -0
  52. data/spec/lib/vanagon/platform/rpm_spec.rb +41 -0
  53. data/spec/lib/vanagon/platform/solaris_11_spec.rb +44 -0
  54. data/spec/lib/vanagon/platform_spec.rb +53 -0
  55. data/spec/lib/vanagon/project/dsl_spec.rb +203 -0
  56. data/spec/lib/vanagon/project_spec.rb +44 -0
  57. data/spec/lib/vanagon/utilities_spec.rb +140 -0
  58. data/templates/Makefile.erb +116 -0
  59. data/templates/deb/changelog.erb +5 -0
  60. data/templates/deb/conffiles.erb +3 -0
  61. data/templates/deb/control.erb +21 -0
  62. data/templates/deb/dirs.erb +3 -0
  63. data/templates/deb/docs.erb +1 -0
  64. data/templates/deb/install.erb +3 -0
  65. data/templates/deb/postinst.erb +46 -0
  66. data/templates/deb/postrm.erb +15 -0
  67. data/templates/deb/prerm.erb +17 -0
  68. data/templates/deb/rules.erb +25 -0
  69. data/templates/osx/postinstall.erb +24 -0
  70. data/templates/osx/preinstall.erb +19 -0
  71. data/templates/osx/project-installer.xml.erb +19 -0
  72. data/templates/rpm/project.spec.erb +217 -0
  73. data/templates/solaris/10/depend.erb +3 -0
  74. data/templates/solaris/10/pkginfo.erb +13 -0
  75. data/templates/solaris/10/postinstall.erb +37 -0
  76. data/templates/solaris/10/preinstall.erb +7 -0
  77. data/templates/solaris/10/preremove.erb +6 -0
  78. data/templates/solaris/10/proto.erb +5 -0
  79. data/templates/solaris/11/p5m.erb +73 -0
  80. metadata +172 -0
@@ -0,0 +1,443 @@
1
+ require 'vanagon/component/dsl'
2
+ require 'vanagon/common'
3
+ require 'json'
4
+
5
+ describe 'Vanagon::Component::DSL' do
6
+ let (:component_block) {
7
+ "component 'test-fixture' do |pkg, settings, platform|
8
+ pkg.load_from_json('spec/fixures/component/test-fixture.json')
9
+ end" }
10
+
11
+ let (:invalid_component_block) {
12
+ "component 'test-fixture' do |pkg, settings, platform|
13
+ pkg.load_from_json('spec/fixures/component/invalid-test-fixture.json')
14
+ end" }
15
+
16
+ let (:dummy_platform_sysv) {
17
+ plat = Vanagon::Platform::DSL.new('debian-6-i386')
18
+ plat.instance_eval("platform 'debian-6-i386' do |plat|
19
+ plat.servicetype 'sysv'
20
+ plat.servicedir '/etc/init.d'
21
+ plat.defaultdir '/etc/default'
22
+ end")
23
+ plat._platform
24
+ }
25
+
26
+ let (:dummy_platform_systemd) {
27
+ plat = Vanagon::Platform::DSL.new('el-7-x86_64')
28
+ plat.instance_eval("platform 'el-7-x86_64' do |plat|
29
+ plat.servicetype 'systemd'
30
+ plat.servicedir '/usr/lib/systemd/system'
31
+ plat.defaultdir '/etc/default'
32
+ end")
33
+ plat._platform
34
+ }
35
+
36
+ let (:dummy_platform_smf) {
37
+ plat = Vanagon::Platform::DSL.new('debian-11-i386')
38
+ plat.instance_eval("platform 'debian-11-i386' do |plat|
39
+ plat.servicetype 'smf'
40
+ plat.servicedir '/var/svc/manifest'
41
+ plat.defaultdir '/lib/svc/method'
42
+ end")
43
+ plat._platform
44
+ }
45
+
46
+ let (:dummy_platform_aix) {
47
+ plat = Vanagon::Platform::DSL.new('aix-7.1-ppc')
48
+ plat.instance_eval("platform 'aix-7.1-ppc' do |plat|
49
+ plat.servicetype 'aix'
50
+ plat.servicedir '/etc/rc.d'
51
+ plat.defaultdir '/etc/rc.d'
52
+ end")
53
+ plat._platform
54
+ }
55
+
56
+
57
+
58
+ let(:platform) { double(Vanagon::Platform) }
59
+
60
+ before do
61
+ allow(platform).to receive(:install).and_return('install')
62
+ end
63
+
64
+ describe '#load_from_json' do
65
+ it "sets the ref and url based on the json fixture" do
66
+ comp = Vanagon::Component::DSL.new('test-fixture', {}, {})
67
+ comp.instance_eval(component_block)
68
+ expect(comp._component.options[:ref]).to eq('3.7.3')
69
+ expect(comp._component.url).to eq('git@github.com:puppetlabs/puppet')
70
+ end
71
+
72
+ it "raises an error on invalid methods/attributes in the json" do
73
+ comp = Vanagon::Component::DSL.new('test-fixture', {}, {})
74
+ expect { comp.instance_eval(invalid_component_block) }.to raise_error(RuntimeError)
75
+ end
76
+ end
77
+
78
+ describe '#configure' do
79
+ it 'sets configure to the value if configure is empty' do
80
+ comp = Vanagon::Component::DSL.new('configure-test', {}, {})
81
+ comp.configure { './configure' }
82
+ expect(comp._component.configure).to eq(['./configure'])
83
+ end
84
+
85
+ it 'appends to the existing configure if not empty' do
86
+ comp = Vanagon::Component::DSL.new('configure-test', {}, {})
87
+ comp.configure { './configure' }
88
+ comp.configure { './test' }
89
+ expect(comp._component.configure).to eq(['./configure', './test'])
90
+ end
91
+ end
92
+
93
+ describe '#build' do
94
+ it 'sets build to the value if build is empty' do
95
+ comp = Vanagon::Component::DSL.new('build-test', {}, {})
96
+ comp.build { './build' }
97
+ expect(comp._component.build).to eq(['./build'])
98
+ end
99
+
100
+ it 'appends to the existing build if not empty' do
101
+ comp = Vanagon::Component::DSL.new('build-test', {}, {})
102
+ comp.build { './build' }
103
+ comp.build { './test' }
104
+ expect(comp._component.build).to eq(['./build', './test'])
105
+ end
106
+ end
107
+
108
+ describe '#install' do
109
+ it 'sets install to the value if install is empty' do
110
+ comp = Vanagon::Component::DSL.new('install-test', {}, {})
111
+ comp.install { './install' }
112
+ expect(comp._component.install).to eq(['./install'])
113
+ end
114
+
115
+ it 'appends to the existing install if not empty' do
116
+ comp = Vanagon::Component::DSL.new('install-test', {}, {})
117
+ comp.install { './install' }
118
+ comp.install { './test' }
119
+ expect(comp._component.install).to eq(['./install', './test'])
120
+ end
121
+ end
122
+
123
+ describe '#apply_patch' do
124
+ it 'adds the patch to the list of patches' do
125
+ comp = Vanagon::Component::DSL.new('patch-test', {}, {})
126
+ comp.apply_patch('patch_file1')
127
+ comp.apply_patch('patch_file2')
128
+ expect(comp._component.patches.count).to eq 2
129
+ expect(comp._component.patches.first.path).to eq 'patch_file1'
130
+ expect(comp._component.patches.last.path).to eq 'patch_file2'
131
+ end
132
+
133
+ it 'can specify strip and fuzz' do
134
+ comp = Vanagon::Component::DSL.new('patch-test', {}, {})
135
+ # This patch must be amazing
136
+ comp.apply_patch('patch_file1', fuzz: 12, strip: 1000000)
137
+ expect(comp._component.patches.count).to eq 1
138
+ expect(comp._component.patches.first.path).to eq 'patch_file1'
139
+ expect(comp._component.patches.first.fuzz).to eq '12'
140
+ expect(comp._component.patches.first.strip).to eq '1000000'
141
+ end
142
+ end
143
+
144
+ describe '#build_requires' do
145
+ it 'adds the build requirement to the list of build requirements' do
146
+ comp = Vanagon::Component::DSL.new('buildreq-test', {}, {})
147
+ comp.build_requires('library1')
148
+ comp.build_requires('library2')
149
+ expect(comp._component.build_requires).to include('library1')
150
+ expect(comp._component.build_requires).to include('library2')
151
+ end
152
+ end
153
+
154
+ describe '#requires' do
155
+ it 'adds the runtime requirement to the list of requirements' do
156
+ comp = Vanagon::Component::DSL.new('requires-test', {}, {})
157
+ comp.requires('library1')
158
+ comp.requires('library2')
159
+ expect(comp._component.requires).to include('library1')
160
+ expect(comp._component.requires).to include('library2')
161
+ end
162
+ end
163
+
164
+ describe '#provides' do
165
+ it 'adds the package provide to the list of provides' do
166
+ comp = Vanagon::Component::DSL.new('provides-test', {}, {})
167
+ comp.provides('thing1')
168
+ comp.provides('thing2')
169
+ expect(comp._component.provides.first.provide).to eq('thing1')
170
+ expect(comp._component.provides.last.provide).to eq('thing2')
171
+ end
172
+
173
+ it 'supports versioned provides' do
174
+ comp = Vanagon::Component::DSL.new('provides-test', {}, {})
175
+ comp.provides('thing1', '1.2.3')
176
+ expect(comp._component.provides.first.provide).to eq('thing1')
177
+ expect(comp._component.provides.first.version).to eq('1.2.3')
178
+ end
179
+ end
180
+
181
+ describe '#replaces' do
182
+ it 'adds the package replacement to the list of replacements' do
183
+ comp = Vanagon::Component::DSL.new('replaces-test', {}, {})
184
+ comp.replaces('thing1')
185
+ comp.replaces('thing2')
186
+ expect(comp._component.replaces.first.replacement).to eq('thing1')
187
+ expect(comp._component.replaces.last.replacement).to eq('thing2')
188
+ end
189
+
190
+ it 'supports versioned replaces' do
191
+ comp = Vanagon::Component::DSL.new('replaces-test', {}, {})
192
+ comp.replaces('thing1', '1.2.3')
193
+ expect(comp._component.replaces.first.replacement).to eq('thing1')
194
+ expect(comp._component.replaces.first.version).to eq('1.2.3')
195
+ end
196
+ end
197
+
198
+ describe '#add_actions' do
199
+ it 'adds the corect preinstall action to the component for rpm platforms' do
200
+ comp = Vanagon::Component::DSL.new('action-test', {}, dummy_platform_sysv)
201
+ comp.add_preinstall_action('chkconfig --list')
202
+ expect(comp._component.preinstall_actions).to include("chkconfig --list")
203
+ end
204
+
205
+ it 'adds the corect postinstall action to the component for rpm platforms' do
206
+ comp = Vanagon::Component::DSL.new('action-test', {}, dummy_platform_sysv)
207
+ comp.add_postinstall_action('chkconfig --list')
208
+ expect(comp._component.postinstall_actions).to include("chkconfig --list")
209
+ end
210
+ end
211
+
212
+ describe '#install_service' do
213
+ it 'adds the correct command to the install for the component for sysv platforms' do
214
+ comp = Vanagon::Component::DSL.new('service-test', {}, dummy_platform_sysv)
215
+ comp.install_service('component-client.init', 'component-client.sysconfig')
216
+ # Look for servicedir creation and copy
217
+ expect(comp._component.install).to include("install -d '/etc/init.d'")
218
+ expect(comp._component.install).to include("cp -p 'component-client.init' '/etc/init.d/service-test'")
219
+
220
+ # Look for defaultdir creation and copy
221
+ expect(comp._component.install).to include("install -d '/etc/default'")
222
+ expect(comp._component.install).to include("cp -p 'component-client.sysconfig' '/etc/default/service-test'")
223
+
224
+ # Look for files and configfiles
225
+ expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('/etc/default/service-test'))
226
+ expect(comp._component.files).to include(Vanagon::Common::Pathname.file('/etc/init.d/service-test', mode: '0755'))
227
+
228
+ # The component should now have a service registered
229
+ expect(comp._component.service.name).to eq('service-test')
230
+ end
231
+
232
+ it 'reads from a file when the OS is AIX for services' do
233
+ comp = Vanagon::Component::DSL.new('service-test', {}, dummy_platform_aix)
234
+ comp.install_service('spec/fixures/component/mcollective.service', nil, 'mcollective')
235
+ expect(comp._component.service.name).to eq('mcollective')
236
+ expect(comp._component.service.service_command).to include('/opt/puppetlabs/puppet/bin/ruby')
237
+ expect(comp._component.service.service_command).not_to include("\n")
238
+ end
239
+
240
+ it 'adds the correct command to the install for the component for systemd platforms' do
241
+ comp = Vanagon::Component::DSL.new('service-test', {}, dummy_platform_systemd)
242
+ comp.install_service('component-client.service', 'component-client.sysconfig')
243
+ # Look for servicedir creation and copy
244
+ expect(comp._component.install).to include("install -d '/usr/lib/systemd/system'")
245
+ expect(comp._component.install).to include("cp -p 'component-client.service' '/usr/lib/systemd/system/service-test.service'")
246
+
247
+ # Look for defaultdir creation and copy
248
+ expect(comp._component.install).to include("install -d '/etc/default'")
249
+ expect(comp._component.install).to include("cp -p 'component-client.sysconfig' '/etc/default/service-test'")
250
+
251
+ # Look for files and configfiles
252
+ expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('/etc/default/service-test'))
253
+ expect(comp._component.files).to include(Vanagon::Common::Pathname.file('/usr/lib/systemd/system/service-test.service', mode: '0644'))
254
+
255
+ # The component should now have a service registered
256
+ expect(comp._component.service.name).to eq('service-test')
257
+ end
258
+
259
+ it 'adds the correct command to the install for smf services using a service_type' do
260
+ comp = Vanagon::Component::DSL.new('service-test', {}, dummy_platform_smf)
261
+ comp.install_service('service.xml', 'service-default-file', service_type: 'network')
262
+ # Look for servicedir creation and copy
263
+ expect(comp._component.install).to include("install -d '/var/svc/manifest/network'")
264
+ expect(comp._component.install).to include("cp -p 'service.xml' '/var/svc/manifest/network/service-test.xml'")
265
+
266
+ # Look for defaultdir creation and copy
267
+ expect(comp._component.install).to include("install -d '/lib/svc/method'")
268
+ expect(comp._component.install).to include("cp -p 'service-default-file' '/lib/svc/method/service-test'")
269
+
270
+ # Look for files and configfiles
271
+ expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('/lib/svc/method/service-test'))
272
+ expect(comp._component.files).to include(Vanagon::Common::Pathname.file('/var/svc/manifest/network/service-test.xml', mode: '0644'))
273
+
274
+ # The component should now have a service registered
275
+ expect(comp._component.service.name).to eq('service-test')
276
+ end
277
+
278
+ it 'adds the correct command to the install for smf services' do
279
+ comp = Vanagon::Component::DSL.new('service-test', {}, dummy_platform_smf)
280
+ comp.install_service('service.xml', 'service-default-file')
281
+ # Look for servicedir creation and copy
282
+ expect(comp._component.install).to include("install -d '/var/svc/manifest'")
283
+ expect(comp._component.install).to include("cp -p 'service.xml' '/var/svc/manifest/service-test.xml'")
284
+
285
+ # Look for defaultdir creation and copy
286
+ expect(comp._component.install).to include("install -d '/lib/svc/method'")
287
+ expect(comp._component.install).to include("cp -p 'service-default-file' '/lib/svc/method/service-test'")
288
+
289
+ # Look for files and configfiles
290
+ expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('/lib/svc/method/service-test'))
291
+ expect(comp._component.files).to include(Vanagon::Common::Pathname.file('/var/svc/manifest/service-test.xml', mode: '0644'))
292
+
293
+ # The component should now have a service registered
294
+ expect(comp._component.service.name).to eq('service-test')
295
+ end
296
+ end
297
+
298
+ describe '#install_file' do
299
+ it 'installs correctly using GNU install on AIX' do
300
+ comp = Vanagon::Component::DSL.new('install-file-test', {}, dummy_platform_aix)
301
+ comp.install_file('thing1', 'place/to/put/thing1')
302
+ expect(comp._component.install).to include("/opt/freeware/bin/install -d 'place/to/put'")
303
+ expect(comp._component.install).to include("cp -p 'thing1' 'place/to/put/thing1'")
304
+ end
305
+
306
+ it 'adds the correct commands to the install to copy the file' do
307
+ comp = Vanagon::Component::DSL.new('install-file-test', {}, platform)
308
+ comp.install_file('thing1', 'place/to/put/thing1')
309
+ expect(comp._component.install).to include("install -d 'place/to/put'")
310
+ expect(comp._component.install).to include("cp -p 'thing1' 'place/to/put/thing1'")
311
+ end
312
+
313
+ it 'adds an owner and group to the installation' do
314
+ comp = Vanagon::Component::DSL.new('install-file-test', {}, platform)
315
+ comp.install_file('thing1', 'place/to/put/thing1', owner: 'bob', group: 'timmy', mode: '0022')
316
+ expect(comp._component.install).to include("install -d 'place/to/put'")
317
+ expect(comp._component.install).to include("cp -p 'thing1' 'place/to/put/thing1'")
318
+ expect(comp._component.files).to include(Vanagon::Common::Pathname.file('place/to/put/thing1', mode: '0022', owner: 'bob', group: 'timmy'))
319
+ end
320
+ end
321
+
322
+ describe 'configfile handling' do
323
+ let(:platform) { double(Vanagon::Platform) }
324
+
325
+ describe 'on anything but solaris 10' do
326
+ before do
327
+ allow(platform).to receive(:name).and_return('debian-8-amd64')
328
+ end
329
+
330
+ describe '#configfile' do
331
+ it 'adds the file to the configfiles list' do
332
+ comp = Vanagon::Component::DSL.new('config-file-test', {}, platform)
333
+ comp.configfile('/place/to/put/thing1')
334
+ expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('/place/to/put/thing1'))
335
+ expect(comp._component.configfiles).not_to include(Vanagon::Common::Pathname.file('/place/to/put/thing1'))
336
+ end
337
+ end
338
+
339
+ describe '#install_configfile' do
340
+ it 'adds the commands to install the configfile' do
341
+ comp = Vanagon::Component::DSL.new('install-config-file-test', {}, platform)
342
+ comp.install_configfile('thing1', 'place/to/put/thing1')
343
+ expect(comp._component.install).to include("install -d 'place/to/put'")
344
+ expect(comp._component.install).to include("cp -p 'thing1' 'place/to/put/thing1'")
345
+ end
346
+
347
+ it 'adds the file to the configfiles list' do
348
+ comp = Vanagon::Component::DSL.new('install-config-file-test', {}, platform)
349
+ comp.install_configfile('thing1', 'place/to/put/thing1')
350
+ expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('place/to/put/thing1'))
351
+ expect(comp._component.files).not_to include(Vanagon::Common::Pathname.file('place/to/put/thing1'))
352
+ end
353
+ end
354
+ end
355
+
356
+ describe 'on solaris 10, do something terrible' do
357
+ before do
358
+ allow(platform).to receive(:name).and_return('solaris-10-x86_64')
359
+ end
360
+
361
+ describe '#configfile' do
362
+ it 'adds the file to the configfiles list' do
363
+ comp = Vanagon::Component::DSL.new('config-file-test', {}, platform)
364
+ comp.configfile('/place/to/put/thing1')
365
+ expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('/place/to/put/thing1.pristine'))
366
+ end
367
+ end
368
+
369
+ describe '#install_configfile' do
370
+ it 'adds the commands to install the configfile' do
371
+ comp = Vanagon::Component::DSL.new('install-config-file-test', {}, platform)
372
+ comp.install_configfile('thing1', 'place/to/put/thing1')
373
+ expect(comp._component.install).to include("install -d 'place/to/put'")
374
+ expect(comp._component.install).to include("cp -p 'thing1' 'place/to/put/thing1'")
375
+ end
376
+
377
+ it 'adds the file to the configfiles list' do
378
+ comp = Vanagon::Component::DSL.new('install-config-file-test', {}, platform)
379
+ comp.install_configfile('thing1', 'place/to/put/thing1')
380
+ expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('place/to/put/thing1.pristine'))
381
+ expect(comp._component.configfiles).not_to include(Vanagon::Common::Pathname.file('place/to/put/thing1'))
382
+ end
383
+ end
384
+ end
385
+ end
386
+
387
+ describe '#link' do
388
+ it 'adds the correct command to the install for the component' do
389
+ comp = Vanagon::Component::DSL.new('link-test', {}, platform)
390
+ comp.link('link-source', '/place/to/put/things')
391
+ expect(comp._component.install).to include("install -d '/place/to/put'")
392
+ expect(comp._component.install).to include("ln -s 'link-source' '/place/to/put/things'")
393
+ end
394
+ end
395
+
396
+ describe '#environment' do
397
+ it 'adds an override to the environment for a component' do
398
+ comp = Vanagon::Component::DSL.new('env-test', {}, {})
399
+ comp.environment({'PATH' => '/usr/local/bin'})
400
+ expect(comp._component.environment).to eq({'PATH' => '/usr/local/bin'})
401
+ end
402
+
403
+ it 'merges against the existing environment' do
404
+ comp = Vanagon::Component::DSL.new('env-test', {}, {})
405
+ comp.environment({'PATH' => '/usr/local/bin'})
406
+ comp.environment({'PATH' => '/usr/bin'})
407
+ comp.environment({'CFLAGS' => '-I /usr/local/bin'})
408
+ expect(comp._component.environment).to eq({'PATH' => '/usr/bin', 'CFLAGS' => '-I /usr/local/bin'})
409
+ end
410
+ end
411
+
412
+ describe '#directory' do
413
+ it 'adds a directory with the desired path to the directory collection for the component' do
414
+ comp = Vanagon::Component::DSL.new('directory-test', {}, {})
415
+ comp.directory('/a/b/c')
416
+ expect(comp._component.directories).to include(Vanagon::Common::Pathname.new('/a/b/c'))
417
+ end
418
+
419
+ it 'adds a directory with the desired mode to the directory collection for the component' do
420
+ comp = Vanagon::Component::DSL.new('directory-test', {}, {})
421
+ comp.directory('/a/b/c', mode: '0755')
422
+ expect(comp._component.directories.first).to eq(Vanagon::Common::Pathname.new('/a/b/c', mode: '0755'))
423
+ end
424
+
425
+ it 'adds a directory with the desired owner to the directory collection for the component' do
426
+ comp = Vanagon::Component::DSL.new('directory-test', {}, {})
427
+ comp.directory('/a/b/c', owner: 'olivia')
428
+ expect(comp._component.directories.first).to eq(Vanagon::Common::Pathname.new('/a/b/c', owner: 'olivia'))
429
+ end
430
+
431
+ it 'adds a directory with the desired group to the directory collection for the component' do
432
+ comp = Vanagon::Component::DSL.new('directory-test', {}, {})
433
+ comp.directory('/a/b/c', group: 'release-engineering')
434
+ expect(comp._component.directories.first).to eq(Vanagon::Common::Pathname.new('/a/b/c', group: 'release-engineering'))
435
+ end
436
+
437
+ it 'adds a directory with the desired attributes to the directory collection for the component' do
438
+ comp = Vanagon::Component::DSL.new('directory-test', {}, {})
439
+ comp.directory('/a/b/c', mode: '0400', owner: 'olivia', group: 'release-engineering')
440
+ expect(comp._component.directories.first).to eq(Vanagon::Common::Pathname.new('/a/b/c', mode: '0400', owner: 'olivia', group: 'release-engineering'))
441
+ end
442
+ end
443
+ end
@@ -0,0 +1,19 @@
1
+ require 'vanagon/component/source/git'
2
+
3
+ describe "Vanagon::Component::Source::Git" do
4
+ let (:url) { 'git://github.com/puppetlabs/facter' }
5
+ let (:ref) { '2.2.0' }
6
+ let (:workdir) { "/tmp" }
7
+
8
+ describe "#dirname" do
9
+ it "returns the name of the repo" do
10
+ git_source = Vanagon::Component::Source::Git.new(url, ref, workdir)
11
+ expect(git_source.dirname).to eq('facter')
12
+ end
13
+
14
+ it "returns the name of the repo and strips .git" do
15
+ git_source = Vanagon::Component::Source::Git.new("#{url}.git", ref, workdir)
16
+ expect(git_source.dirname).to eq('facter')
17
+ end
18
+ end
19
+ end