Skip to content

Commit d8e9188

Browse files
committed
some spec fixtures
1 parent 5a05d53 commit d8e9188

File tree

3 files changed

+15
-77
lines changed

3 files changed

+15
-77
lines changed
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
bash-3.1.17 GNU Bourne Again Shell
2-
bzip2-1.0.3 block-sorting file compressor, unencumbered
3-
expat-2.0.0 XML 1.0 parser written in C
4-
gettext-0.14.5p1 GNU gettext
5-
libiconv-1.9.2p3 character set conversion library
6-
lzo-1.08p1 portable speedy lossless data compression library
7-
openvpn-2.0.6 easy-to-use, robust, and highly configurable VPN
8-
python-2.4.3p0 interpreted object-oriented programming language
9-
vim-7.0.42-no_x11 vi clone, many additional features
10-
wget-1.10.2p0 retrieve files from the web via HTTP, HTTPS and FTP
1+
autoconf--%2.13
2+
autoconf--%2.56
3+
bash--
4+
postfix--ldap%stable
5+
puppet--%8
6+
zstd--

spec/fixtures/unit/provider/package/openbsd/pkginfo_flavors.list

Lines changed: 0 additions & 2 deletions
This file was deleted.

spec/unit/provider/package/openbsd_spec.rb

Lines changed: 9 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,6 @@
55
let(:package) { Puppet::Type.type(:package).new(:name => 'bash', :provider => 'openbsd') }
66
let(:provider) { described_class.new(package) }
77

8-
def expect_read_from_pkgconf(lines)
9-
pkgconf = double(:readlines => lines)
10-
expect(Puppet::FileSystem).to receive(:exist?).with('/etc/pkg.conf').and_return(true)
11-
expect(File).to receive(:open).with('/etc/pkg.conf', 'rb').and_return(pkgconf)
12-
end
13-
14-
def expect_pkgadd_with_source(source)
15-
expect(provider).to receive(:pkgadd).with([source]) do
16-
expect(ENV).not_to have_key('PKG_PATH')
17-
end
18-
end
19-
20-
def expect_pkgadd_with_env_and_name(source, &block)
21-
expect(ENV).not_to have_key('PKG_PATH')
22-
23-
expect(provider).to receive(:pkgadd).with([provider.resource[:name]]) do
24-
expect(ENV).to have_key('PKG_PATH')
25-
expect(ENV['PKG_PATH']).to eq(source)
26-
end
27-
expect(provider).to receive(:execpipe).with(['/bin/pkg_info', '-I', provider.resource[:name]]).and_yield('')
28-
29-
yield
30-
31-
expect(ENV).not_to be_key('PKG_PATH')
32-
end
33-
348
context 'provider features' do
359
it { is_expected.to be_installable }
3610
it { is_expected.to be_install_options }
@@ -61,20 +35,23 @@ def expect_pkgadd_with_env_and_name(source, &block)
6135

6236
it "should return all packages when invoked" do
6337
fixture = File.read(my_fixture('pkginfo.list'))
64-
expect(described_class).to receive(:execpipe).with(%w{/bin/pkg_info -a}).and_yield(fixture)
38+
expect(described_class).to receive(:execpipe).with(%w{/bin/pkg_info -a -z}).and_yield(fixture)
6539
expect(described_class.instances.map(&:name).sort).to eq(
66-
%w{bash bzip2 expat gettext libiconv lzo openvpn python vim wget}.sort
40+
%w{autoconf%2.13 autoconf%2.56 bash postfix%stable puppet%8}.sort
6741
)
6842
end
6943

7044
it "should return all flavors if set" do
71-
fixture = File.read(my_fixture('pkginfo_flavors.list'))
72-
expect(described_class).to receive(:execpipe).with(%w{/bin/pkg_info -a}).and_yield(fixture)
45+
fixture = File.read(my_fixture('pkginfo.list'))
46+
expect(described_class).to receive(:execpipe).with(%w{/bin/pkg_info -a -z}).and_yield(fixture)
7347
instances = described_class.instances.map {|p| {:name => p.get(:name),
7448
:ensure => p.get(:ensure), :flavor => p.get(:flavor)}}
7549
expect(instances.size).to eq(2)
76-
expect(instances[0]).to eq({:name => 'bash', :ensure => '3.1.17', :flavor => 'static'})
77-
expect(instances[1]).to eq({:name => 'vim', :ensure => '7.0.42', :flavor => 'no_x11'})
50+
expect(instances[0]).to eq({:name => 'autoconf%2.13', :ensure => 'present', :flavor => nil})
51+
expect(instances[1]).to eq({:name => 'autoconf%2.56', :ensure => 'present', :flavor => nil})
52+
expect(instances[2]).to eq({:name => 'bash', :ensure => 'present', :flavor => nil})
53+
expect(instances[3]).to eq({:name => 'postfix%stable', :ensure => 'present', :flavor => 'ldap'})
54+
expect(instances[4]).to eq({:name => 'puppet%8', :ensure => 'present', :flavor => nil})
7855
end
7956
end
8057

@@ -86,39 +63,6 @@ def expect_pkgadd_with_env_and_name(source, &block)
8663
end
8764
end
8865

89-
context "#latest" do
90-
before do
91-
provider.resource[:source] = '/tmp/tcsh.tgz'
92-
provider.resource[:name] = 'tcsh'
93-
allow(provider).to receive(:pkginfo).with('tcsh--')
94-
end
95-
96-
it "should return the ensure value if the package is already installed" do
97-
allow(provider).to receive(:properties).and_return({:ensure => '4.2.45'})
98-
allow(provider).to receive(:pkginfo).with('-Q', 'tcsh--')
99-
expect(provider.latest).to eq('4.2.45')
100-
end
101-
102-
it "should recognize a new version" do
103-
pkginfo_query = 'tcsh-6.18.01p1'
104-
allow(provider).to receive(:pkginfo).with('-Q', 'tcsh--').and_return(pkginfo_query)
105-
expect(provider.latest).to eq('6.18.01p1')
106-
end
107-
108-
it "should recognize a newer version" do
109-
allow(provider).to receive(:properties).and_return({:ensure => '1.6.8'})
110-
pkginfo_query = 'tcsh-1.6.10'
111-
allow(provider).to receive(:pkginfo).with('-Q', 'tcsh--').and_return(pkginfo_query)
112-
expect(provider.latest).to eq('1.6.10')
113-
end
114-
115-
it "should recognize a package that is already the newest" do
116-
pkginfo_query = 'tcsh-6.18.01p0 (installed)'
117-
allow(provider).to receive(:pkginfo).with('-Q', 'tcsh--').and_return(pkginfo_query)
118-
expect(provider.latest).to eq('6.18.01p0')
119-
end
120-
end
121-
12266
context "#get_full_name" do
12367
it "should return the full unversioned package name when updating with a flavor" do
12468
provider.resource[:ensure] = 'latest'

0 commit comments

Comments
 (0)