diff options
author | Eric Saxby <sax@livinginthepast.org> | 2013-08-29 17:29:36 -0700 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2013-09-25 12:51:34 -0700 |
commit | 031bce02c29fd9a2811ad9b63692e1d880e35e84 (patch) | |
tree | 4b63a2de9a5deb1d65e3ea513fdeb1bf98b2b609 | |
parent | 0a4cb24ef2b17a303c0949b824170c4d8a96857a (diff) | |
download | chef-031bce02c29fd9a2811ad9b63692e1d880e35e84.tar.gz |
[CHEF-4507] Smartos package provider to match resource package_name
-rw-r--r-- | lib/chef/provider/package/smartos.rb | 4 | ||||
-rw-r--r-- | spec/unit/provider/package/smartos_spec.rb | 18 |
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/chef/provider/package/smartos.rb b/lib/chef/provider/package/smartos.rb index b17f6f2564..a099337a7b 100644 --- a/lib/chef/provider/package/smartos.rb +++ b/lib/chef/provider/package/smartos.rb @@ -64,14 +64,14 @@ class Chef pkg = shell_out!("/opt/local/bin/pkgin se #{new_resource.package_name}", :env => nil, :returns => [0,1]) pkg.stdout.each_line do |line| case line - when /^#{name}/ + when /^#{new_resource.package_name}/ name, version = line.split[0].split(/-([^-]+)$/) end end @candidate_version = version version end - + def install_package(name, version) Chef::Log.debug("#{@new_resource} installing package #{name} version #{version}") package = "#{name}-#{version}" diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb index 47db00988c..71ea3fab04 100644 --- a/spec/unit/provider/package/smartos_spec.rb +++ b/spec/unit/provider/package/smartos_spec.rb @@ -69,6 +69,24 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do end + describe "candidate_version" do + it "should return the candidate_version variable if already setup" do + @provider.candidate_version = "2.1.1" + @provider.should_not_receive(:shell_out!) + @provider.candidate_version + end + + it "should lookup the candidate_version if the variable is not already set" do + search = mock() + search.should_receive(:each_line). + and_yield("something-varnish-1.1.1 something varnish like\n"). + and_yield("varnish-2.3.4 actual varnish\n") + @shell_out = mock('shell_out!', :stdout => search) + @provider.should_receive(:shell_out!).with('/opt/local/bin/pkgin se varnish', :env => nil, :returns => [0,1]).and_return(@shell_out) + @provider.candidate_version.should == "2.3.4" + end + end + describe "when manipulating a resource" do it "run pkgin and install the package" do |