summaryrefslogtreecommitdiff
path: root/spec/unit/provider/package/openbsd_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider/package/openbsd_spec.rb')
-rwxr-xr-xspec/unit/provider/package/openbsd_spec.rb75
1 files changed, 66 insertions, 9 deletions
diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb
index 8d4f079fe..712f9cfda 100755
--- a/spec/unit/provider/package/openbsd_spec.rb
+++ b/spec/unit/provider/package/openbsd_spec.rb
@@ -17,7 +17,7 @@ describe provider_class do
def expect_pkgadd_with_source(source)
provider.expects(:pkgadd).with do |fullname|
ENV.should_not be_key('PKG_PATH')
- fullname.should == source
+ fullname.should == [source]
end
end
@@ -28,7 +28,7 @@ describe provider_class do
ENV.should be_key('PKG_PATH')
ENV['PKG_PATH'].should == source
- fullname.should == provider.resource[:name]
+ fullname.should == [provider.resource[:name]]
end
provider.expects(:execpipe).with(['/bin/pkg_info', '-I', provider.resource[:name]]).yields('')
@@ -37,6 +37,15 @@ describe provider_class do
ENV.should_not be_key('PKG_PATH')
end
+ describe 'provider features' do
+ it { should be_installable }
+ it { should be_install_options }
+ it { should be_uninstallable }
+ it { should be_uninstall_options }
+ it { should be_upgradeable }
+ it { should be_versionable }
+ end
+
before :each do
# Stub some provider methods to avoid needing the actual software
# installed, so we can test on whatever platform we want.
@@ -45,7 +54,7 @@ describe provider_class do
provider_class.stubs(:command).with(:pkgdelete).returns('/bin/pkg_delete')
end
- context "::instances" do
+ context "#instances" do
it "should return nil if execution failed" do
provider_class.expects(:execpipe).raises(Puppet::ExecutionFailure, 'wawawa')
provider_class.instances.should be_nil
@@ -69,7 +78,7 @@ describe provider_class do
instances = provider_class.instances.map {|p| {:name => p.get(:name),
:ensure => p.get(:ensure), :flavor => p.get(:flavor)}}
instances.size.should == 2
- instances[0].should == {:name => 'bash', :ensure => '3.1.17', :flavor => 'static'}
+ instances[0].should == {:name => 'bash', :ensure => '3.1.17', :flavor => 'static'}
instances[1].should == {:name => 'vim', :ensure => '7.0.42', :flavor => 'no_x11'}
end
end
@@ -100,7 +109,7 @@ describe provider_class do
end
it "should install correctly when given a directory-unlike source" do
- source = '/whatever.pkg'
+ source = '/whatever.tgz'
provider.resource[:source] = source
expect_pkgadd_with_source(source)
@@ -224,6 +233,46 @@ describe provider_class do
}.to raise_error(Puppet::Error, /No valid installpath found in \/etc\/pkg\.conf and no source was set/)
end
end
+
+ it 'should use install_options as Array' do
+ provider.resource[:source] = '/tma1/'
+ provider.resource[:install_options] = ['-r', '-z']
+ provider.expects(:pkgadd).with(['-r', '-z', 'bash'])
+ provider.install
+ end
+ end
+
+ context "#latest" do
+ before do
+ provider.resource[:source] = '/tmp/tcsh.tgz'
+ provider.resource[:name] = 'tcsh'
+ provider.stubs(:pkginfo).with('tcsh')
+ end
+
+ it "should return the ensure value if the package is already installed" do
+ provider.stubs(:properties).returns({:ensure => '4.2.45'})
+ provider.stubs(:pkginfo).with('-Q', 'tcsh')
+ provider.latest.should == '4.2.45'
+ end
+
+ it "should recognize a new version" do
+ pkginfo_query = 'tcsh-6.18.01p1'
+ provider.stubs(:pkginfo).with('-Q', 'tcsh').returns(pkginfo_query)
+ provider.latest.should == '6.18.01p1'
+ end
+
+ it "should recognize a newer version" do
+ provider.stubs(:properties).returns({:ensure => '1.6.8'})
+ pkginfo_query = 'tcsh-1.6.10'
+ provider.stubs(:pkginfo).with('-Q', 'tcsh').returns(pkginfo_query)
+ provider.latest.should == '1.6.10'
+ end
+
+ it "should recognize a package that is already the newest" do
+ pkginfo_query = 'tcsh-6.18.01p0 (installed)'
+ provider.stubs(:pkginfo).with('-Q', 'tcsh').returns(pkginfo_query)
+ provider.latest.should == '6.18.01p0'
+ end
end
context "#get_version" do
@@ -233,8 +282,8 @@ describe provider_class do
end
it "should return the package version if in the output" do
- fixture = File.read(my_fixture('pkginfo.list'))
- provider.expects(:execpipe).with(%w{/bin/pkg_info -I bash}).yields(fixture)
+ output = 'bash-3.1.17 GNU Bourne Again Shell'
+ provider.expects(:execpipe).with(%w{/bin/pkg_info -I bash}).yields(output)
provider.get_version.should == '3.1.17'
end
@@ -279,7 +328,7 @@ describe provider_class do
provider.install_options.should == ['-Darch=vax']
end
end
-
+
context "#uninstall_options" do
it "should return nill by default" do
provider.uninstall_options.should be_nil
@@ -300,7 +349,7 @@ describe provider_class do
provider.uninstall_options.should == ['-Dbaddepend=1']
end
end
-
+
context "#uninstall" do
describe 'when uninstalling' do
it 'should use erase to purge' do
@@ -308,5 +357,13 @@ describe provider_class do
provider.purge
end
end
+
+ describe 'with uninstall_options' do
+ it 'should use uninstall_options as Array' do
+ provider.resource[:uninstall_options] = ['-q', '-c']
+ provider.expects(:pkgdelete).with(['-q', '-c'], 'bash')
+ provider.uninstall
+ end
+ end
end
end