Skip to content

Commit

Permalink
Merge pull request chocolatey-archive#77 from ferventcoder/ticket/mas…
Browse files Browse the repository at this point in the history
…ter/MODULES-4562_use_original_choco

(MODULES-4562) Use actual choco.exe
glennsarti authored May 5, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 66b46ac + 47e2cdf commit 82a205b
Showing 5 changed files with 36 additions and 36 deletions.
46 changes: 23 additions & 23 deletions examples/init.pp
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# The baseline for module testing used by Puppet Labs is that each manifest
# should have a corresponding test manifest that declares that class or defined
# type.
#
# Tests are then run by using puppet apply --noop (to check for compilation errors
# and view a log of events) or by fully applying the test in a virtual environment
# (to compare the resulting system state to the desired state).
#
# Learn more about module testing here: http://docs.puppetlabs.com/guides/tests_smoke.html
#
# With symlinks on Windows, please run the following command an administrative command prompt (substituting the proper directories):

package { $pkg:
ensure => 'latest',
provider => 'chocolatey',
}

# mklink /D C:\ProgramData\PuppetLabs\puppet\etc\modules\chocolatey C:\code\puppetlabs\puppetlabs-chocolatey
# mklink /D C:\ProgramData\PuppetLabs\code\environments\production\modules\chocolatey C:\code\puppetlabs\puppetlabs-chocolatey

chocolateysource { 'local':
location => 'c:\packages',
}
# The baseline for module testing used by Puppet Labs is that each manifest
# should have a corresponding test manifest that declares that class or defined
# type.
#
# Tests are then run by using puppet apply --noop (to check for compilation errors
# and view a log of events) or by fully applying the test in a virtual environment
# (to compare the resulting system state to the desired state).
#
# Learn more about module testing here: http://docs.puppetlabs.com/guides/tests_smoke.html
#
# With symlinks on Windows, please run the following command an administrative command prompt (substituting the proper directories):

package { $pkg:
ensure => 'latest',
provider => 'chocolatey',
}

# mklink /D C:\ProgramData\PuppetLabs\puppet\etc\modules\chocolatey C:\code\puppetlabs\puppetlabs-chocolatey
# mklink /D C:\ProgramData\PuppetLabs\code\environments\production\modules\chocolatey C:\code\puppetlabs\puppetlabs-chocolatey

chocolateysource { 'local':
location => 'c:\packages',
}
8 changes: 4 additions & 4 deletions lib/puppet_x/chocolatey/chocolatey_common.rb
Original file line number Diff line number Diff line change
@@ -30,12 +30,12 @@ def chocolatey_command
# it installs
chocoInstallPath = PuppetX::Chocolatey::ChocolateyInstall.install_path

chocopath = (chocoInstallPath if (chocoInstallPath && file_exists?("#{chocoInstallPath}\\bin\\choco.exe"))) ||
('C:\ProgramData\chocolatey' if file_exists?('C:\ProgramData\chocolatey\bin\choco.exe')) ||
('C:\Chocolatey' if file_exists?('C:\Chocolatey\bin\choco.exe')) ||
chocopath = (chocoInstallPath if (chocoInstallPath && file_exists?("#{chocoInstallPath}\\choco.exe"))) ||
('C:\ProgramData\chocolatey' if file_exists?('C:\ProgramData\chocolatey\choco.exe')) ||
('C:\Chocolatey' if file_exists?('C:\Chocolatey\choco.exe')) ||
"#{ENV['ALLUSERSPROFILE']}\\chocolatey"

chocopath += '\bin\choco.exe'
chocopath += '\choco.exe'
else
chocopath = 'choco.exe'
end
2 changes: 1 addition & 1 deletion lib/puppet_x/chocolatey/chocolatey_version.rb
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ class ChocolateyVersion

def self.version
version = nil
choco_path = "#{PuppetX::Chocolatey::ChocolateyInstall.install_path}\\bin\\choco.exe"
choco_path = "#{PuppetX::Chocolatey::ChocolateyInstall.install_path}\\choco.exe"
if Puppet::Util::Platform.windows? && File.exist?(choco_path)
begin
# call `choco -v`
12 changes: 6 additions & 6 deletions spec/unit/puppet_x/chocolatey/chocolatey_common_spec.rb
Original file line number Diff line number Diff line change
@@ -15,18 +15,18 @@
context ".chocolatey_command" do
it "should find chocolatey install location based on PuppetX::Chocolatey::ChocolateyInstall", :if => Puppet.features.microsoft_windows? do
PuppetX::Chocolatey::ChocolateyInstall.expects(:install_path).returns('c:\dude')
PuppetX::Chocolatey::ChocolateyCommon.expects(:file_exists?).with('c:\dude\bin\choco.exe').returns(true)
PuppetX::Chocolatey::ChocolateyCommon.expects(:file_exists?).with('c:\dude\choco.exe').returns(true)

PuppetX::Chocolatey::ChocolateyCommon.chocolatey_command.should == 'c:\dude\bin\choco.exe'
PuppetX::Chocolatey::ChocolateyCommon.chocolatey_command.should == 'c:\dude\choco.exe'
end

it "should find chocolatey install location based on default location", :if => Puppet.features.microsoft_windows? do
PuppetX::Chocolatey::ChocolateyInstall.expects(:install_path).returns('c:\dude')
PuppetX::Chocolatey::ChocolateyCommon.expects(:file_exists?).with('c:\dude\bin\choco.exe').returns(false)
PuppetX::Chocolatey::ChocolateyCommon.expects(:file_exists?).with('C:\ProgramData\chocolatey\bin\choco.exe').returns(false)
PuppetX::Chocolatey::ChocolateyCommon.expects(:file_exists?).with('C:\Chocolatey\bin\choco.exe').returns(false)
PuppetX::Chocolatey::ChocolateyCommon.expects(:file_exists?).with('c:\dude\choco.exe').returns(false)
PuppetX::Chocolatey::ChocolateyCommon.expects(:file_exists?).with('C:\ProgramData\chocolatey\choco.exe').returns(false)
PuppetX::Chocolatey::ChocolateyCommon.expects(:file_exists?).with('C:\Chocolatey\choco.exe').returns(false)

PuppetX::Chocolatey::ChocolateyCommon.chocolatey_command.should == "#{ENV['ALLUSERSPROFILE']}\\chocolatey\\bin\\choco.exe"
PuppetX::Chocolatey::ChocolateyCommon.chocolatey_command.should == "#{ENV['ALLUSERSPROFILE']}\\chocolatey\\choco.exe"
end
end

4 changes: 2 additions & 2 deletions spec/unit/puppet_x/chocolatey/chocolatey_version_spec.rb
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
context "when Chocolatey is installed" do
before :each do
PuppetX::Chocolatey::ChocolateyInstall.expects(:install_path).returns('c:\dude')
File.expects(:exist?).with('c:\dude\bin\choco.exe').returns(true)
File.expects(:exist?).with('c:\dude\choco.exe').returns(true)
end

it "should return the value from running choco -v" do
@@ -63,7 +63,7 @@
context "When Chocolatey is not installed" do
before :each do
PuppetX::Chocolatey::ChocolateyInstall.expects(:install_path).returns(nil)
File.expects(:exist?).with('\bin\choco.exe').returns(false)
File.expects(:exist?).with('\choco.exe').returns(false)
end

it "should return nil" do

0 comments on commit 82a205b

Please sign in to comment.