diff options
author | Scott Bonds <scott@ggr.com> | 2014-10-27 09:21:29 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-11-13 13:09:16 -0800 |
commit | 6bc96348553458e7c6e2b9aea28c2a368d43d0d3 (patch) | |
tree | bd3d3c4a03f26c49f5c554e68903d22b1e4232fb /spec | |
parent | 9d7178b4ae849c1b155ac2bbb0a50a1518c525ac (diff) | |
download | chef-6bc96348553458e7c6e2b9aea28c2a368d43d0d3.tar.gz |
simplify openbsd package provider
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/package/openbsd_spec.rb | 299 |
1 files changed, 4 insertions, 295 deletions
diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb index ecf8402727..37d0d844a9 100644 --- a/spec/unit/provider/package/openbsd_spec.rb +++ b/spec/unit/provider/package/openbsd_spec.rb @@ -19,14 +19,7 @@ require 'spec_helper' require 'ostruct' -def running_compatible_os - @os ||= `uname`.downcase.strip - @os_version ||= `uname -r`.strip - @os_architecture ||= `uname -m`.downcase.strip - @os == 'openbsd' && @os_version == '5.5' && @os_architecture == 'amd64' -end - -describe Chef::Provider::Package::Openbsd, 'find_package', :if => running_compatible_os do +describe Chef::Provider::Package::Openbsd do before(:each) do @node = Chef::Node.new @@ -35,295 +28,13 @@ describe Chef::Provider::Package::Openbsd, 'find_package', :if => running_compat @run_context = Chef::RunContext.new(@node, {}, @events) end - describe "plain package name (zsh)" do - before do - @name = 'zsh' - @new_resource = Chef::Resource::Package.new(@name) - @current_resource = Chef::Resource::Package.new(@name) - @provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - @provider.sqlports(:skip_installation => true) - @info = @provider.find_package(@name) - end - - it "should parse as a plain package with no version" do - @info[:short_name].should == 'zsh' - @info[:short_version].should == '5.0.2' - @info[:pkgspec].should == 'zsh-*' - @info[:fullpkgname].should == 'zsh-5.0.2' - @info[:fullpkgpath].should == 'shells/zsh' - end - - it "should translate to a port path" do - @provider.port_path.should == '/usr/ports/shells/zsh' - end - - it "should have a valid repo candidate version" do - @provider.repo_candidate_version.should == '5.0.2' - end - - it "should have a valid port candidate version" do - @provider.port_candidate_version.should == '5.0.2' - end - - end - - describe "package name with unavailable version (zsh-5.0.10)" do - before do - @name = 'zsh-5.0.10' - @new_resource = Chef::Resource::Package.new(@name) - @current_resource = Chef::Resource::Package.new(@name) - @provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - @provider.sqlports(:skip_installation => true) - end - - it "should raise an exception when the requested version does not match whats available in the repo" do - expect {@provider.find_package(@name)}.to raise_error Chef::Exceptions::Package - end - -end - - describe "package name with available version (zsh-5.0.2)" do - before do - @name = 'zsh-5.0.2' - @new_resource = Chef::Resource::Package.new(@name) - @current_resource = Chef::Resource::Package.new(@name) - @provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - @provider.sqlports(:skip_installation => true) - @info = @provider.find_package(@name) - end - - it "should parse as a plain package with no version" do - @info[:short_name].should == 'zsh' - @info[:short_version].should == '5.0.2' - @info[:pkgspec].should == 'zsh-*' - @info[:fullpkgname].should == 'zsh-5.0.2' - @info[:fullpkgpath].should == 'shells/zsh' - end - - it "should translate to a port path" do - @provider.port_path.should == '/usr/ports/shells/zsh' - end - - it "should have a valid repo candidate version" do - @provider.repo_candidate_version.should == '5.0.2' - end - - it "should have a valid port candidate version" do - @provider.port_candidate_version.should == '5.0.2' - end - - end - - describe "package with version and flavor (mutt-1.5.22p0v0-sasl)" do - before do - @name = 'mutt-1.5.22p0v0-sasl' - @new_resource = Chef::Resource::Package.new(@name) - @current_resource = Chef::Resource::Package.new(@name) - @provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - @provider.sqlports(:skip_installation => true) - @info = @provider.find_package(@name) - end - - it "should parse as a plain package with no version" do - @info[:short_name].should == 'mutt' - @info[:short_version].should == '1.5.22' - @info[:pkgspec].should == 'mutt-*' - @info[:fullpkgname].should == 'mutt-1.5.22p0v0-sasl' - @info[:fullpkgpath].should == 'mail/mutt/snapshot,sasl' - end - - it "should translate to a port path" do - @provider.port_path.should == '/usr/ports/mail/mutt/snapshot' - end - - it "should have a valid repo candidate version" do - @provider.repo_candidate_version.should == '1.5.22p0v0-sasl' - end - - it "should have a valid port candidate version" do - @provider.port_candidate_version.should == '1.5.22' - end - - end - - describe "package with subpackage (gnome-extra)" do - before do - @name = 'gnome-extra' - @new_resource = Chef::Resource::Package.new(@name) - @current_resource = Chef::Resource::Package.new(@name) - @provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - @provider.sqlports(:skip_installation => true) - @info = @provider.find_package(@name) - end - - it "should parse as a plain package with no version" do - @info[:short_name].should == 'gnome-extra' - @info[:short_version].should == '3.10.2' - @info[:pkgspec].should == 'gnome-extra-*' - @info[:fullpkgname].should == 'gnome-extra-3.10.2' - @info[:fullpkgpath].should == 'meta/gnome,-extra' - end - - it "should translate to a port path" do - @provider.port_path.should == '/usr/ports/meta/gnome' - end - - it "should have a valid repo candidate version" do - @provider.repo_candidate_version.should == '3.10.2' - end - - it "should have a valid port candidate version" do - @provider.port_candidate_version.should == '3.10.2' - end - - end - - describe "port path with 'main' subpackage (mail/gmime,-main)" do - before do - @name = 'mail/gmime,-main' - @new_resource = Chef::Resource::Package.new(@name) - @current_resource = Chef::Resource::Package.new(@name) - @provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - @provider.sqlports(:skip_installation => true) - @info = @provider.find_package(@name) - end - - it "should parse as a plain package with no version" do - @info[:short_name].should == 'gmime' - @info[:short_version].should == '2.6.19' - @info[:pkgspec].should == 'gmime-*' - @info[:fullpkgname].should == 'gmime-2.6.19' - @info[:fullpkgpath].should == 'mail/gmime,-main' - end - - it "should translate to a port path" do - @provider.port_path.should == '/usr/ports/mail/gmime' - end - - it "should have a valid repo candidate version" do - @provider.repo_candidate_version.should == '2.6.19' - end - - it "should have a valid port candidate version" do - @provider.port_candidate_version.should == '2.6.19' - end - - end - - describe "port path with non-'main' subpackage (mail/gmime,-mono)" do - before do - @name = 'mail/gmime,-mono' - @new_resource = Chef::Resource::Package.new(@name) - @current_resource = Chef::Resource::Package.new(@name) - @provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - @provider.sqlports(:skip_installation => true) - @info = @provider.find_package(@name) - end - - it "should parse as a plain package with no version" do - @info[:short_name].should == 'gmime-sharp' - @info[:short_version].should == '2.6.19' - @info[:pkgspec].should == 'gmime-sharp-*' - @info[:fullpkgname].should == 'gmime-sharp-2.6.19' - @info[:fullpkgpath].should == @name - end - - it "should translate to a port path" do - @provider.port_path.should == '/usr/ports/mail/gmime' - end - - it "should have a valid repo candidate version" do - @provider.repo_candidate_version.should == '2.6.19' - end - - it "should have a valid port candidate version" do - @provider.port_candidate_version.should == '2.6.19' - end - - end - - describe "package with a dash in the name, multiple major versions, and different package and port versions (php-zip-5.4.24)" do - before do - @name = 'php-zip-5.4.24' - @new_resource = Chef::Resource::Package.new(@name) - @current_resource = Chef::Resource::Package.new(@name) - @provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - @provider.sqlports(:skip_installation => true) - @info = @provider.find_package(@name) - end - - it "should parse as a plain package with no version" do - @info[:short_name].should == 'php-zip' - @info[:short_version].should == '5.4.24' - @info[:pkgspec].should == 'php-zip->=5.4,<5.5' - @info[:fullpkgname].should == 'php-zip-5.4.24' - @info[:fullpkgpath].should == 'lang/php/5.4,-zip' - end - - it "should translate to a port path" do - @provider.port_path.should == '/usr/ports/lang/php/5.4' - end - - it "should have a valid repo candidate version" do - @provider.repo_candidate_version.should == '5.4.24' - end - - it "should have a valid port candidate version" do - @provider.port_candidate_version.should =~ /5\.4\.\d*/ - end - - end - - describe "another package name to parse, for good measure (clamav)" do - before do - @name = 'clamav' - @new_resource = Chef::Resource::Package.new(@name) - @current_resource = Chef::Resource::Package.new(@name) - @provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - @provider.sqlports(:skip_installation => true) - @info = @provider.find_package(@name) - end - - it "should parse as a plain package with no version" do - @info[:short_name].should == 'clamav' - @info[:short_version].should == '0.98.1' - @info[:pkgspec].should == 'clamav-*' - @info[:fullpkgname].should == 'clamav-0.98.1' - @info[:fullpkgpath].should == 'security/clamav' - end - - it "should translate to a port path" do - @provider.port_path.should == '/usr/ports/security/clamav' - end - - it "should have a valid repo candidate version" do - @provider.repo_candidate_version.should == '0.98.1' - end - - it "should have a valid port candidate version" do - @provider.port_candidate_version.should == '0.98.4' - end - - end - describe "install a package" do before do - @name = 'zzuf' + @name = 'ihavetoes' @new_resource = Chef::Resource::Package.new(@name) @current_resource = Chef::Resource::Package.new(@name) @provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context) @provider.current_resource = @current_resource - @provider.sqlports(:skip_installation => true) - @info = @provider.find_package(@name) end it "should run the installation command" do expect(@provider).to receive(:shell_out!).with( @@ -339,17 +50,15 @@ end describe "delete a package" do before do - @name = 'sqlports' + @name = 'ihavetoes' @new_resource = Chef::Resource::Package.new(@name) @current_resource = Chef::Resource::Package.new(@name) @provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context) @provider.current_resource = @current_resource - @provider.sqlports(:skip_installation => true) - @info = @provider.find_package(@name) end it "should run the command to delete the installed package" do expect(@provider).to receive(:shell_out!).with( - "pkg_delete sqlports", :env=>nil + "pkg_delete #{@name}", :env=>nil ) {OpenStruct.new :status => true} @provider.remove_package(@name, nil) end |