forked from chocolatey-archive/puppet-chocolatey
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(MODULES-3275) Chocolatey module automation
Tests for installing and removing packages with and without UTF-8
- Loading branch information
Erick Banks
committed
Jun 29, 2016
1 parent
00f9044
commit 42df9af
Showing
5 changed files
with
132 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
tests/reference/tests/chocolateypackage/install_and_remove_good_package.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require 'chocolatey_helper' | ||
require 'beaker-windows' | ||
test_name 'MODULES-3037 - 97729 Install known good package via manifest and remove via manifest' | ||
confine(:to, :platform => 'windows') | ||
|
||
# arrange | ||
package_name = 'vlc' | ||
package_exe_path = %{C:\\'Program Files\\VideoLAN\\VLC\\vlc.exe'} | ||
package_uninstall_command = %{cmd.exe /C C:\\'Program Files\\VideoLAN\\VLC\\uninstall.exe' /S} | ||
|
||
chocolatey_package_manifest = <<-PP | ||
package { "#{package_name}": | ||
ensure => present, | ||
provider => chocolatey, | ||
source => 'http://nexus.delivery.puppetlabs.net/service/local/nuget/choco-pipeline-tests/' | ||
} | ||
PP | ||
|
||
# teardown | ||
teardown do | ||
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result| | ||
if (result.output =~ /True/i) | ||
on(agent, exec_ps_cmd("#{package_uninstall_command}")) | ||
end | ||
end | ||
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result| | ||
assert_match(/False/i, result.output, "#{package_name} was present after uninstall command called.") | ||
end | ||
end | ||
|
||
#validate | ||
step "should not have valid version of #{package_name}" | ||
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result| | ||
assert_match(/False/i, result.output, "#{package_name} was present before application of manifest.") | ||
end | ||
|
||
|
||
#act | ||
step 'Apply manifest' | ||
apply_manifest(chocolatey_package_manifest, :catch_failures => true) do |result| | ||
assert_match(/Notice\: \/Stage\[main\]\/Main\/Package\[#{package_name}\]\/ensure\: created/, result.stdout, "stdout did not report package creation of #{package_name}") | ||
end | ||
|
||
#validate | ||
step "should have valid version of #{package_name}" | ||
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result| | ||
assert_match(/True/i, result.output, "#{package_name} was not present after application of manifest.") | ||
end | ||
|
||
#arrange | ||
chocolatey_package_manifest = <<-PP | ||
package { "#{package_name}": | ||
ensure => absent, | ||
provider => chocolatey, | ||
} | ||
PP | ||
|
||
#act | ||
step "Uninstall #{package_name} package via manifest" | ||
apply_manifest(chocolatey_package_manifest, :catch_failures => true) do |result| | ||
#validate | ||
assert_match(/Stage\[main\]\/Main\/Package\[#{package_name}\]\/ensure\: removed/, result.stdout, "stdout did not report package removal of #{package_name}") | ||
end | ||
|
65 changes: 65 additions & 0 deletions
65
tests/reference/tests/chocolateypackage/install_and_remove_good_package_utf-8.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
require 'chocolatey_helper' | ||
require 'beaker-windows' | ||
test_name 'MODULES-3037 - C97738 Install known good package with utf-8 via manifest and remove via manifest' | ||
confine(:to, :platform => 'windows') | ||
|
||
# arrange | ||
package_name = '竹ChocolateyGUIÖ' | ||
package_exe_path = %{C:\\'Program Files (x86)\\ChocolateyGUI\\ChocolateyGUI.exe'} | ||
package_uninstall_command = %{msiexec /x C:\\ProgramData\\chocolatey\\temp\\chocolatey\\竹ChocolateyGUIÖ\\0.13.2\\竹ChocolateyGUIÖInstall.msi /q}.force_encoding("UTF-8") | ||
|
||
chocolatey_package_manifest = <<-PP | ||
package { "#{package_name}": | ||
ensure => present, | ||
provider => chocolatey, | ||
source => 'http://nexus.delivery.puppetlabs.net/service/local/nuget/choco-pipeline-tests/' | ||
} | ||
PP | ||
|
||
# teardown | ||
teardown do | ||
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result| | ||
if (result.output =~ /True/i) | ||
on(agent, exec_ps_cmd("#{package_uninstall_command}")) | ||
end | ||
end | ||
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result| | ||
assert_match(/False/i, result.output, "#{package_name} was present after uninstall.") | ||
end | ||
end | ||
|
||
#validate | ||
step "should not have valid version of #{package_name}" | ||
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result| | ||
assert_match(/False/i, result.output, "#{package_name} was present before application of manifest.") | ||
end | ||
|
||
|
||
#act | ||
step 'Apply manifest' | ||
apply_manifest(chocolatey_package_manifest, :catch_failures => true) do |result| | ||
assert_match(/Notice\: \/Stage\[main\]\/Main\/Package\[#{package_name}\]\/ensure\: created/, result.stdout, "stdout did not report package creation of #{package_name}") | ||
end | ||
|
||
#validate | ||
step "should have valid version of #{package_name}" | ||
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result| | ||
assert_match(/True/i, result.output, "#{package_name} was not present after application of manifest.") | ||
end | ||
|
||
#arrange | ||
chocolatey_package_manifest = <<-PP | ||
package { "#{package_name}": | ||
ensure => absent, | ||
provider => chocolatey, | ||
} | ||
PP | ||
|
||
#act | ||
step "Uninstall #{package_name} package via manifest" | ||
apply_manifest(chocolatey_package_manifest, :catch_failures => true) do |result| | ||
#validate | ||
expect_failure('Expected to fail because of MODULES-3541') do | ||
assert_match(/Stage\[main\]\/Main\/Package\[#{package_name}\]\/ensure\: removed/, result.stdout, "stdout did not report package removal of #{package_name}") | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.