vanagon 0.5.0 → 0.5.1

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -0
  3. data/lib/vanagon/common/pathname.rb +3 -1
  4. data/lib/vanagon/component.rb +5 -2
  5. data/lib/vanagon/component/dsl.rb +10 -3
  6. data/lib/vanagon/component/source/git.rb +3 -3
  7. data/lib/vanagon/component/source/http.rb +11 -19
  8. data/lib/vanagon/driver.rb +1 -1
  9. data/lib/vanagon/engine/base.rb +4 -3
  10. data/lib/vanagon/engine/docker.rb +1 -0
  11. data/lib/vanagon/engine/hardware.rb +1 -0
  12. data/lib/vanagon/engine/local.rb +1 -0
  13. data/lib/vanagon/engine/pooler.rb +1 -0
  14. data/lib/vanagon/platform.rb +6 -2
  15. data/lib/vanagon/platform/deb.rb +1 -1
  16. data/lib/vanagon/platform/dsl.rb +24 -0
  17. data/lib/vanagon/platform/osx.rb +2 -2
  18. data/lib/vanagon/platform/rpm.rb +1 -1
  19. data/lib/vanagon/platform/solaris_10.rb +1 -1
  20. data/lib/vanagon/platform/solaris_11.rb +1 -1
  21. data/lib/vanagon/platform/windows.rb +241 -0
  22. data/lib/vanagon/project.rb +7 -2
  23. data/lib/vanagon/utilities.rb +14 -5
  24. data/{templates → resources}/Makefile.erb +3 -3
  25. data/{templates → resources}/deb/changelog.erb +0 -0
  26. data/{templates → resources}/deb/conffiles.erb +0 -0
  27. data/{templates → resources}/deb/control.erb +0 -0
  28. data/{templates → resources}/deb/dirs.erb +0 -0
  29. data/{templates → resources}/deb/docs.erb +0 -0
  30. data/{templates → resources}/deb/install.erb +0 -0
  31. data/{templates → resources}/deb/postinst.erb +0 -0
  32. data/{templates → resources}/deb/postrm.erb +0 -0
  33. data/{templates → resources}/deb/preinst.erb +0 -0
  34. data/{templates → resources}/deb/prerm.erb +0 -0
  35. data/{templates → resources}/deb/rules.erb +2 -0
  36. data/{templates → resources}/osx/postinstall.erb +0 -0
  37. data/{templates → resources}/osx/preinstall.erb +0 -0
  38. data/{templates → resources}/osx/project-installer.xml.erb +0 -0
  39. data/{templates → resources}/rpm/project.spec.erb +2 -1
  40. data/{templates → resources}/solaris/10/depend.erb +0 -0
  41. data/{templates → resources}/solaris/10/pkginfo.erb +0 -0
  42. data/{templates → resources}/solaris/10/postinstall.erb +0 -0
  43. data/{templates → resources}/solaris/10/preinstall.erb +0 -0
  44. data/{templates → resources}/solaris/10/preremove.erb +0 -0
  45. data/{templates → resources}/solaris/10/proto.erb +0 -0
  46. data/{templates → resources}/solaris/11/p5m.erb +0 -0
  47. data/resources/windows/nuget/chocolateyInstall.ps1 +28 -0
  48. data/resources/windows/nuget/chocolateyUninstall.ps1 +24 -0
  49. data/resources/windows/nuget/project.nuspec.erb +31 -0
  50. data/resources/windows/wix/service.component.wxs.erb +55 -0
  51. data/spec/lib/vanagon/component/dsl_spec.rb +31 -1
  52. data/spec/lib/vanagon/component/source/git_spec.rb +14 -0
  53. data/spec/lib/vanagon/component/source/http_spec.rb +10 -1
  54. data/spec/lib/vanagon/engine/pooler_spec.rb +1 -1
  55. data/spec/lib/vanagon/platform/windows_spec.rb +43 -0
  56. data/spec/lib/vanagon/utilities_spec.rb +7 -0
  57. metadata +32 -25
@@ -232,6 +232,11 @@ class Vanagon
232
232
  files = ['file-list', 'bill-of-materials']
233
233
  files.push get_files.map(&:path)
234
234
  files.push get_configfiles.map(&:path)
235
+ if @platform.is_windows?
236
+ files.flatten.map { |f| "$$(cygpath --mixed --long-name '#{f}')" }
237
+ else
238
+ files.flatten
239
+ end
235
240
  end
236
241
 
237
242
  # Generate a bill-of-materials: a listing of the components and their
@@ -248,7 +253,7 @@ class Vanagon
248
253
  def pack_tarball_command
249
254
  tar_root = "#{@name}-#{@version}"
250
255
  ["mkdir -p '#{tar_root}'",
251
- %('#{@platform.tar}' -cf - -T #{get_tarball_files.join(" ")} | ( cd '#{tar_root}/'; '#{@platform.tar}' xfp -)),
256
+ %('#{@platform.tar}' -cf - -T "#{get_tarball_files.join('" "')}" | ( cd '#{tar_root}/'; '#{@platform.tar}' xfp -)),
252
257
  %('#{@platform.tar}' -cf - #{tar_root}/ | gzip -9c > #{tar_root}.tar.gz)].join("\n\t")
253
258
  end
254
259
 
@@ -258,7 +263,7 @@ class Vanagon
258
263
  # @param workdir [String] full path to the workdir to send the evaluated template
259
264
  # @return [String] full path to the generated Makefile
260
265
  def make_makefile(workdir)
261
- erb_file(File.join(VANAGON_ROOT, "templates/Makefile.erb"), File.join(workdir, "Makefile"))
266
+ erb_file(File.join(VANAGON_ROOT, "resources/Makefile.erb"), File.join(workdir, "Makefile"))
262
267
  end
263
268
 
264
269
  # Generates a bill-of-materials and writes the contents to the workdir for use in
@@ -146,11 +146,19 @@ class Vanagon
146
146
  # Simple wrapper around git command line executes the given commands and
147
147
  # returns the results.
148
148
  #
149
- # @param commands [String] The commands to be run
149
+ # @param command_string [String] The commands to be run
150
+ # @param raise_error [boolean] if this function should raise an error
151
+ # on a git failure
150
152
  # @return [String] The output of the command
151
- def git(*commands)
153
+ def git(command_string, raise_error = false)
152
154
  git_bin = find_program_on_path('git')
153
- %x(#{git_bin} #{commands.join(' ')})
155
+ output = %x(#{git_bin} #{command_string})
156
+ if raise_error
157
+ unless $?.success?
158
+ raise %(git #{command_string} failed)
159
+ end
160
+ end
161
+ return output
154
162
  end
155
163
 
156
164
  # Determines if the given directory is a git repo or not
@@ -159,7 +167,7 @@ class Vanagon
159
167
  # @return [true, false] True if the directory is a git repo, false otherwise
160
168
  def is_git_repo?(directory = Dir.pwd)
161
169
  Dir.chdir(directory) do
162
- git('rev-parse', '--git-dir', '> /dev/null 2>&1')
170
+ git('rev-parse --git-dir > /dev/null 2>&1')
163
171
  $?.success?
164
172
  end
165
173
  end
@@ -173,7 +181,7 @@ class Vanagon
173
181
  def git_version(directory = Dir.pwd)
174
182
  if is_git_repo?(directory)
175
183
  Dir.chdir(directory) do
176
- version = git('describe', '--tags', '2> /dev/null').chomp
184
+ version = git('describe --tags 2> /dev/null').chomp
177
185
  if version.empty?
178
186
  warn "Directory '#{directory}' cannot be versioned by git. Maybe it hasn't been tagged yet?"
179
187
  end
@@ -211,6 +219,7 @@ class Vanagon
211
219
  args << " -p #{port} "
212
220
  args << " -o UserKnownHostsFile=/dev/null"
213
221
  args << " -o StrictHostKeyChecking=no"
222
+ args << " -o ForwardAgent=yes" if ENV['VANAGON_SSH_AGENT']
214
223
  return ssh + args
215
224
  end
216
225
 
@@ -13,14 +13,14 @@ file-list-before-build:
13
13
  <%- if dirnames.empty? -%>
14
14
  touch file-list-before-build
15
15
  <%- else -%>
16
- (find -L <%= dirnames.join(' ') %> 2>/dev/null || find <%= dirnames.join(' ') %> -follow 2>/dev/null) | sort | uniq > file-list-before-build
16
+ (<%= @platform.find %> -L "<%= dirnames.join('" "') %>" 2>/dev/null || <%= @platform.find %> "<%= dirnames.join('" "') %>" -follow 2>/dev/null) | <%= "xargs -I[] cygpath --mixed --long-name --absolute [] |" if @platform.is_windows? %> <%= @platform.sort %> | uniq > file-list-before-build
17
17
  <%- end -%>
18
18
 
19
19
  file-list-after-build: <%= @components.map {|comp| comp.name }.join(" ") %>
20
20
  <%- if dirnames.empty? -%>
21
21
  touch file-list-after-build
22
22
  <%- else -%>
23
- (find -L <%= dirnames.join(' ') %> 2>/dev/null || find <%= dirnames.join(' ') %> -follow 2>/dev/null) | sort | uniq > file-list-after-build
23
+ (<%= @platform.find %> -L "<%= dirnames.join('" "') %>" 2>/dev/null || <%= @platform.find %> "<%= dirnames.join('" "') %>" -follow 2>/dev/null) | <%= "xargs -I[] cygpath --mixed --long-name --absolute [] |" if @platform.is_windows? %> <%= @platform.sort %> | uniq > file-list-after-build
24
24
  <%- end -%>
25
25
 
26
26
  <%= @name %>-<%= @version %>.tar.gz: file-list <%= @cleanup ? 'cleanup-components' : '' %>
@@ -43,7 +43,7 @@ file-list: file-list-before-build <%= @name %>-project
43
43
 
44
44
  <%- dirnames.each do |dir| -%>
45
45
  <%= dir %>: file-list-before-build
46
- mkdir -p <%= dir %>
46
+ mkdir -p '<%= dir %>'
47
47
  <%- end %>
48
48
 
49
49
  <%- if @cleanup -%>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -21,5 +21,7 @@ override_dh_auto_install:
21
21
 
22
22
  override_dh_shlibdeps:
23
23
 
24
+ override_dh_usrlocal:
25
+
24
26
  %:
25
27
  dh $@
@@ -253,7 +253,8 @@ if [ -e %{_localstatedir}/lib/rpm-state/%{name}/upgrade ] ; then
253
253
  fi
254
254
  <%- end -%>
255
255
 
256
- %files -f %{SOURCE1}
256
+ %files <%- unless get_directories.empty? -%>-f %{SOURCE1}<%- end -%>
257
+
257
258
  <%- unless @bill_of_materials -%>
258
259
  %doc bill-of-materials
259
260
  <%- end -%>
@@ -0,0 +1,28 @@
1
+ $toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
2
+ $fileList = Join-Path -path $toolsDir -childpath "file-list.txt"
3
+
4
+ if (!(Test-Path -path "$fileList")) {
5
+ Throw "Unable to find file '$fileList', cannot proceed with install"
6
+ }
7
+
8
+ $lines = Get-Content "$fileList"
9
+ foreach ($destination in $lines) {
10
+ $originFile = "$destination" -replace '^[a-zA-Z]:/',''
11
+ $origin = Join-Path -path "$toolsDir" -childpath "$originFile"
12
+ if (Test-Path -path "$origin") {
13
+ $parent = Split-Path -path "$destination" -parent
14
+ if (!(Test-Path -path "$parent")) {
15
+ New-Item -ItemType directory -Path "$parent"
16
+ }
17
+ if (Test-Path -path "$destination") {
18
+ Write-Debug "Overwriting '$destination'"
19
+ }
20
+ Copy-Item -path "$origin" -destination "$destination" -Force
21
+ } else {
22
+ # If the item we are trying to copy over does not exist in our source directory,
23
+ # we assume it is an empty directory and simply create one in its place. There is
24
+ # a possibility that this will hide an error where there is actually a missing
25
+ # file. However, this is such a slim possibity, this action was deemed safe.
26
+ New-Item -ItemType directory -Path "$destination"
27
+ }
28
+ }
@@ -0,0 +1,24 @@
1
+ $toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
2
+ $fileList = Join-Path -path $toolsDir -childpath "file-list.txt"
3
+
4
+ if (!(Test-Path -path "$fileList")) {
5
+ Throw "Unable to find file '$fileList', cannot proceed with uninstall"
6
+ }
7
+
8
+ $lines = Get-Content "$fileList"
9
+ foreach ($file in $lines) {
10
+ if (Test-Path -path "$file") {
11
+ # We cannot guarentee a directory is only populated with files from
12
+ # this package, so we cannot whole-sale remove directories. We could
13
+ # check to see if a directory is empty after we remove all the files,
14
+ # but that would still end up with some reminantes of our skeletal
15
+ # directory structure. It doesn't seem worth it ATM. As is, only remove
16
+ # things that are files, and do not remove any directories.
17
+ if (!((Get-Item "$file") -is [System.IO.DirectoryInfo])) {
18
+ Write-Debug "Removing '$file'"
19
+ remove-item -Path "$file" -Force
20
+ }
21
+ } else {
22
+ Write-Debug "Skipping missing file '$file'"
23
+ }
24
+ }
@@ -0,0 +1,31 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
3
+ <metadata>
4
+ <id><%= "#{@name}-#{@platform.architecture}" %></id>
5
+ <version><%= @platform.nuget_package_version(@version, @release) %></version>
6
+ <title><%= @name %></title>
7
+ <authors><%= @vendor.match(/^(.*) <.*>$/)[1] %></authors>
8
+ <owners><%= @vendor.match(/^(.*) <.*>$/)[1] %></owners>
9
+ <projectUrl><%= @homepage %></projectUrl>
10
+ <packageSourceUrl><%= "https://github.com/puppetlabs/#{project}-vanagon" %></packageSourceUrl>
11
+ <projectSourceUrl><%= "https://github.com/puppetlabs/#{project}" %></projectSourceUrl>
12
+ <docsUrl><%= @homepage %></docsUrl>
13
+ <mailingListUrl><%= @homepage %></mailingListUrl>
14
+ <bugTrackerUrl><%= @homepage %></bugTrackerUrl>
15
+ <licenseUrl><%= @homepage %></licenseUrl>
16
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
17
+ <description>
18
+ <%= @description %>
19
+ </description>
20
+ <summary><%= @description.lines.first.chomp %></summary>
21
+ <releaseNotes><%= @homepage %></releaseNotes>
22
+ <copyright><%= @vendor.match(/^(.*) <.*>$/)[1] %></copyright>
23
+ <tags>puppet configuration management infrastructure automation facter hiera mco mcollective marionette collective</tags>
24
+ <provides><%= get_replaces.map { |replace| "#{replace.replacement}" }.join(" ") %></provides>
25
+ <replaces><%= get_replaces.map { |replace| "#{replace.replacement}" }.join(" ") %></replaces>
26
+ </metadata>
27
+ <files>
28
+ <file src="tools\**" target="tools" />
29
+ </files>
30
+ </package>
31
+ <!-- character encoding: “UTF-8” -->
@@ -0,0 +1,55 @@
1
+ <?xml version='1.0' encoding='windows-1252'?>
2
+ <Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
3
+ <Fragment>
4
+ <%- get_services.each do |service| -%>
5
+ <%- service.options.each do |component| -%>
6
+ <DirectoryRef Id="<%= component[:directory_ref] %>">
7
+ <Component Id='<%= component[:id] %>' Guid="<%= component[:guid] %>" <%= "Win64=\"#{component[:win64]}\"" unless component[:win64].nil? %>>
8
+ <%- unless component[:conditions].nil? -%>
9
+ <%- component[:conditions].each do |condition| -%>
10
+ <Condition>
11
+ <%= condition %>
12
+ </Condition>
13
+ <%- end -%>
14
+ <%- end -%>
15
+ <File Id="<%= component[:file][:id] %>" KeyPath="yes" Source="<%= component[:file][:source] %>" />
16
+ <ServiceInstall Id="<%= component[:serviceinstall][:id] %>"
17
+ Account="[PUPPET_AGENT_ACCOUNT_DOMAIN]\[PUPPET_AGENT_ACCOUNT_USER]"
18
+ Password="[PUPPET_AGENT_ACCOUNT_PASSWORD]"
19
+ Description="<%= component[:serviceinstall][:description] %>"
20
+ DisplayName="<%= component[:serviceinstall][:displayname] %>"
21
+ Interactive="no"
22
+ Name="<%= component[:serviceinstall][:name] %>"
23
+ Start="<%= component[:serviceinstall][:start] %>"
24
+ Type="ownProcess"
25
+ ErrorControl="normal"
26
+ Vital="yes"
27
+ <%- unless component[:serviceinstall][:arguments].nil? -%>
28
+ Arguments="<%= component[:serviceinstall][:arguments] %>"
29
+ <%- end -%>
30
+ />
31
+ <%- unless component[:registries].nil? -%>
32
+ <RegistryKey Root="<%= component[:registries][:root] %>" Key="<%= component[:registries][:key] %>">
33
+ <%- unless component[:registries][:values].nil? -%>
34
+ <%- component[:registries][:values].each do |value| -%>
35
+ <RegistryValue Name="<%= value[:name] %>" Value="<%= value[:value] %>" Type="<%= value[:type] %>" <%= "Action=\"#{value[:action]}\"" unless value[:action].nil? %> />
36
+ <%- end -%>
37
+ <%- end -%>
38
+ <%- unless component[:registries][:keys].nil? -%>
39
+ <%- component[:registries][:keys].each do |key| -%>
40
+ <RegistryKey Key="<%= key[:name] %>">
41
+ <%- key[:values].each do |value| -%>
42
+ <RegistryValue <%= "Name=\"#{value[:name]}\"" unless value[:name].nil? %> Value="<%= value[:value] %>" Type="<%= value[:type] %>" />
43
+ <%- end -%>
44
+ </RegistryKey>
45
+ <%- end -%>
46
+ <%- end -%>
47
+ </RegistryKey>
48
+ <%- end -%>
49
+ <ServiceControl Id="<%= component[:servicecontrol][:id] %>" <%= "Start=\"#{component[:servicecontrol][:start]}\"" unless component[:servicecontrol][:start].nil? %> Stop="both" Remove="uninstall" Name="<%= component[:servicecontrol][:name] %>" Wait="yes" />
50
+ </Component>
51
+ </DirectoryRef>
52
+ <%- end -%>
53
+ <%- end -%>
54
+ </Fragment>
55
+ </Wix>
@@ -59,6 +59,7 @@ end" }
59
59
 
60
60
  before do
61
61
  allow(platform).to receive(:install).and_return('install')
62
+ allow(platform).to receive(:copy).and_return('cp')
62
63
  end
63
64
 
64
65
  describe '#load_from_json' do
@@ -183,6 +184,35 @@ end" }
183
184
  comp = Vanagon::Component::DSL.new('patch-test', {}, {})
184
185
  expect { comp.apply_patch('patch_file1', after: 'delivery') }.to raise_error(Vanagon::Error)
185
186
  end
187
+
188
+ it 'can specify a directory where the patch should be applied' do
189
+ comp = Vanagon::Component::DSL.new('patch-test', {}, {})
190
+ comp.apply_patch('patch_file1', destination: 'random/install/directory')
191
+ expect(comp._component.patches.count).to eq 1
192
+ expect(comp._component.patches.first.path).to eq 'patch_file1'
193
+ expect(comp._component.patches.first.destination).to eq 'random/install/directory'
194
+ end
195
+
196
+ it 'can specify when to try to apply the patch' do
197
+ comp = Vanagon::Component::DSL.new('patch-test', {}, {})
198
+ comp.apply_patch('patch_file1', after: 'install')
199
+ expect(comp._component.patches.count).to eq 1
200
+ expect(comp._component.patches.first.path).to eq 'patch_file1'
201
+ expect(comp._component.patches.first.after).to eq 'install'
202
+ end
203
+
204
+ it 'will default the patch timing to after the source is unpacked' do
205
+ comp = Vanagon::Component::DSL.new('patch-test', {}, {})
206
+ comp.apply_patch('patch_file1')
207
+ expect(comp._component.patches.count).to eq 1
208
+ expect(comp._component.patches.first.path).to eq 'patch_file1'
209
+ expect(comp._component.patches.first.after).to eq 'unpack'
210
+ end
211
+
212
+ it 'will fail if the user wants to install the patch at an unsupported step' do
213
+ comp = Vanagon::Component::DSL.new('patch-test', {}, {})
214
+ expect { comp.apply_patch('patch_file1', after: 'delivery') }.to raise_error(Vanagon::Error)
215
+ end
186
216
  end
187
217
 
188
218
  describe '#build_requires' do
@@ -548,7 +578,7 @@ end" }
548
578
  comp = Vanagon::Component::DSL.new('link-test', {}, platform)
549
579
  comp.link('link-source', '/place/to/put/things')
550
580
  expect(comp._component.install).to include("install -d '/place/to/put'")
551
- expect(comp._component.install).to include("ln -s 'link-source' '/place/to/put/things'")
581
+ expect(comp._component.install).to include("([[ '/place/to/put/things' -ef 'link-source' ]] || ln -s 'link-source' '/place/to/put/things')")
552
582
  end
553
583
  end
554
584
 
@@ -6,6 +6,7 @@ describe "Vanagon::Component::Source::Git" do
6
6
  let (:workdir) { "/tmp" }
7
7
 
8
8
  describe "#dirname" do
9
+ after(:each) { %x(rm -rf #{workdir}/facter) }
9
10
  it "returns the name of the repo" do
10
11
  git_source = Vanagon::Component::Source::Git.new(url, ref, workdir)
11
12
  expect(git_source.dirname).to eq('facter')
@@ -16,4 +17,17 @@ describe "Vanagon::Component::Source::Git" do
16
17
  expect(git_source.dirname).to eq('facter')
17
18
  end
18
19
  end
20
+
21
+ describe "#fetch" do
22
+ after(:each) { %x(rm -rf #{workdir}/facter) }
23
+ it "raises error on clone failure" do
24
+ #this test has a spelling error for the git repo V this is on purpose
25
+ git_source = Vanagon::Component::Source::Git.new("#{url}l.git", ref, workdir)
26
+ expect { git_source.fetch }.to raise_error(RuntimeError, "git clone #{url}l.git failed")
27
+ end
28
+ it "raises error on checkout failure" do
29
+ git_source = Vanagon::Component::Source::Git.new("#{url}", "999.9.9", workdir)
30
+ expect { git_source.fetch }.to raise_error(RuntimeError, "git checkout 999.9.9 failed")
31
+ end
32
+ end
19
33
  end
@@ -30,7 +30,7 @@ describe "Vanagon::Component::Source::Http" do
30
30
 
31
31
  describe "#get_extension" do
32
32
  it "returns the extension for valid extensions" do
33
- (Vanagon::Component::Source::Http::ARCHIVE_EXTENSIONS + Vanagon::Component::Source::Http::NON_ARCHIVE_EXTENSIONS).each do |ext|
33
+ Vanagon::Component::Source::Http::ARCHIVE_EXTENSIONS.each do |ext|
34
34
  filename = "#{file_base}#{ext}"
35
35
  url = File.join(base_url, filename)
36
36
  http_source = Vanagon::Component::Source::Http.new(url, md5sum, workdir)
@@ -39,5 +39,14 @@ describe "Vanagon::Component::Source::Http" do
39
39
  expect(http_source.get_extension).to eq(ext)
40
40
  end
41
41
  end
42
+
43
+ it "is able to download non archive extensions" do
44
+ ["gpg.txt", "foo.service", "configi.json", "config.repo.txt", "noextensionfile"].each do |filename|
45
+ url = File.join(base_url, filename)
46
+ http_source = Vanagon::Component::Source::Http.new(url, md5sum, workdir)
47
+ expect(http_source).to receive(:download).and_return(filename)
48
+ http_source.fetch
49
+ end
50
+ end
42
51
  end
43
52
  end
@@ -1,7 +1,7 @@
1
1
  require 'vanagon/engine/pooler'
2
2
 
3
3
  describe 'Vanagon::Engine::Pooler' do
4
- let (:platform) { double(Vanagon::Platform) }
4
+ let (:platform) { double(Vanagon::Platform, :target_user => 'root') }
5
5
  let (:platform_with_vcloud_name) {
6
6
  plat = Vanagon::Platform::DSL.new('debian-6-i386')
7
7
  plat.instance_eval("platform 'debian-6-i386' do |plat|
@@ -0,0 +1,43 @@
1
+ require 'vanagon/platform'
2
+
3
+ describe "Vanagon::Platform::Windows" do
4
+ platforms =[
5
+ {
6
+ :name => "windows-2012r2-x64",
7
+ :os_name => "windows",
8
+ :os_version => "2012r2",
9
+ :architecture => "x64",
10
+ :output_dir => "windows/x64",
11
+ :output_dir_with_target => "windows/thing/x64",
12
+ :target_user => "Administrator",
13
+ :block => %Q[ platform "windows-2012r2-x64" do |plat| end ]
14
+ },
15
+ ]
16
+
17
+ platforms.each do |plat|
18
+ context "on #{plat[:name]} we should behave ourselves" do
19
+ let(:platform) { plat }
20
+ let(:cur_plat) { Vanagon::Platform::DSL.new(plat[:name]) }
21
+
22
+ before do
23
+ cur_plat.instance_eval(plat[:block])
24
+ end
25
+
26
+ describe "#output_dir" do
27
+ it "returns an output dir consistent with the packaging repo" do
28
+ expect(cur_plat._platform.output_dir).to eq(plat[:output_dir])
29
+ end
30
+
31
+ it "adds the target repo in the right way" do
32
+ expect(cur_plat._platform.output_dir('thing')).to eq(plat[:output_dir_with_target])
33
+ end
34
+ end
35
+
36
+ describe '#target_user' do
37
+ it "sets the target_user to 'Administrator'" do
38
+ expect(cur_plat._platform.target_user).to eq(plat[:target_user])
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end