|
15 | 15 | before :each do |
16 | 16 | # Stub some provider methods to avoid needing the actual software |
17 | 17 | # installed, so we can test on whatever platform we want. |
18 | | - allow(described_class).to receive(:command).with(:pkginfo).and_return('/bin/pkg_info') |
19 | | - allow(described_class).to receive(:command).with(:pkgadd).and_return('/bin/pkg_add') |
20 | | - allow(described_class).to receive(:command).with(:pkgdelete).and_return('/bin/pkg_delete') |
| 18 | + allow(described_class).to receive(:command).with(:pkginfo).and_return('/usr/sbin/pkg_info') |
| 19 | + allow(described_class).to receive(:command).with(:pkgadd).and_return('/usr/sbin/pkg_add') |
| 20 | + allow(described_class).to receive(:command).with(:pkgdelete).and_return('/usr/sbin/pkg_delete') |
21 | 21 |
|
22 | 22 | allow(Puppet::FileSystem).to receive(:exist?) |
23 | 23 | end |
24 | 24 |
|
25 | 25 | context "#instances" do |
26 | 26 | it "should return nil if execution failed" do |
27 | | - expect(described_class).to receive(:pkgadd).and_raise(Puppet::ExecutionFailure, 'wawawa') |
| 27 | + expect(provider).to receive(:pkginfo).and_raise(Puppet::ExecutionFailure, 'wawawa') |
28 | 28 | expect(described_class.instances).to be_nil |
29 | 29 | end |
30 | 30 |
|
31 | 31 | it "should return the empty set if no packages are listed" do |
32 | | - expect(described_class).to receive(:execpipe).with(%w{/bin/pkg_info -a}).and_yield(StringIO.new('')) |
| 32 | + expect(described_class).to receive(:execpipe).with(%w{/usr/sbin/pkg_info -a}).and_yield(StringIO.new('')) |
33 | 33 | expect(described_class.instances).to be_empty |
34 | 34 | end |
35 | 35 |
|
36 | 36 | it "should return all packages when invoked" do |
37 | 37 | fixture = File.read(my_fixture('pkginfo.list')) |
38 | | - expect(described_class).to receive(:execpipe).with(%w{/bin/pkg_info -a -z}).and_yield(fixture) |
| 38 | + expect(described_class).to receive(:execpipe).with(%w{/usr/sbin/pkg_info -a -z}).and_yield(fixture) |
39 | 39 | expect(described_class.instances.map(&:name).sort).to eq( |
40 | 40 | %w{autoconf%2.13 autoconf%2.56 bash postfix%stable puppet%8}.sort |
41 | 41 | ) |
42 | 42 | end |
43 | 43 |
|
44 | 44 | it "should return all flavors if set" do |
45 | 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) |
| 46 | + expect(described_class).to receive(:execpipe).with(%w{/usr/sbin/pkg_info -a -z}).and_yield(fixture) |
47 | 47 | instances = described_class.instances.map {|p| {:name => p.get(:name), |
48 | 48 | :ensure => p.get(:ensure), :flavor => p.get(:flavor)}} |
49 | 49 | expect(instances.size).to eq(2) |
|
84 | 84 |
|
85 | 85 | it "should lookup the correct version" do |
86 | 86 | output = 'bash-3.1.17 GNU Bourne Again Shell' |
87 | | - expect(provider).to receive(:execpipe).with(%w{/bin/pkg_info -I bash}).and_yield(output) |
| 87 | + expect(provider).to receive(:execpipe).with(%w{/usr/sbin/pkg_info -I bash}).and_yield(output) |
88 | 88 | expect(provider.get_full_name).to eq('bash-3.1.17') |
89 | 89 | end |
90 | 90 |
|
91 | 91 | it "should lookup the correction version with flavors" do |
92 | 92 | provider.resource[:name] = 'fossil' |
93 | 93 | provider.resource[:flavor] = 'static' |
94 | 94 | output = 'fossil-1.29v0-static simple distributed software configuration management' |
95 | | - expect(provider).to receive(:execpipe).with(%w{/bin/pkg_info -I fossil}).and_yield(output) |
| 95 | + expect(provider).to receive(:execpipe).with(%w{/usr/sbin/pkg_info -I fossil}).and_yield(output) |
96 | 96 | expect(provider.get_full_name).to eq('fossil-1.29v0-static') |
97 | 97 | end |
98 | 98 | end |
|
105 | 105 |
|
106 | 106 | it "should return the package version if in the output" do |
107 | 107 | output = 'bash-3.1.17 GNU Bourne Again Shell' |
108 | | - expect(provider).to receive(:execpipe).with(%w{/bin/pkg_info -I bash}).and_yield(output) |
| 108 | + expect(provider).to receive(:execpipe).with(%w{/usr/sbin/pkg_info -I bash}).and_yield(output) |
109 | 109 | expect(provider.get_version).to eq('3.1.17') |
110 | 110 | end |
111 | 111 |
|
112 | 112 | it "should return the empty string if the package is not present" do |
113 | 113 | provider.resource[:name] = 'zsh' |
114 | | - expect(provider).to receive(:execpipe).with(%w{/bin/pkg_info -I zsh}).and_yield(StringIO.new('')) |
| 114 | + expect(provider).to receive(:execpipe).with(%w{/usr/sbin/pkg_info -I zsh}).and_yield(StringIO.new('')) |
115 | 115 | expect(provider.get_version).to eq('') |
116 | 116 | end |
117 | 117 | end |
|
0 commit comments