|
86 | 86 | provider.run_preseed |
87 | 87 | end |
88 | 88 |
|
| 89 | + context "When listing all instances" do |
| 90 | + let(:args) { ['-W', '--showformat', %Q{'${Status} ${Package} ${Version}\\n'}] } |
| 91 | + let(:bash_version) { '4.2-5ubuntu3' } |
| 92 | + let(:bash_installed_output) { "install ok installed bash #{bash_version}\n" } |
| 93 | + let(:bash_installed_io) { StringIO.new(bash_installed_output) } |
| 94 | + let(:execpipe_args) { args.unshift('myquery') } |
| 95 | + |
| 96 | + before do |
| 97 | + allow(described_class).to receive(:command).with(:dpkgquery).and_return('myquery') |
| 98 | + allow(described_class).to receive(:command).with(:aptmark, 'showmanual').and_return('bash\n') |
| 99 | + end |
| 100 | + |
| 101 | + it 'creates and return an instance for a single apt-mark entry' do |
| 102 | + expect(Puppet::Util::Execution).to receive(:execpipe).with(execpipe_args).and_yield(bash_installed_io) |
| 103 | + installed = double('bash', :mark => :manual) |
| 104 | + expect(described_class).to receive(:new).with( |
| 105 | + :ensure => "4.2-5ubuntu3", |
| 106 | + :error => "ok", |
| 107 | + :desired => "install", |
| 108 | + :name => "bash", |
| 109 | + :status => "installed", |
| 110 | + :provider => :apt, |
| 111 | + ).and_return(installed) |
| 112 | + allow(installed).to receive(:name) |
| 113 | + |
| 114 | + expect(described_class.instances).to eq([installed]) |
| 115 | + end |
| 116 | + end |
89 | 117 | describe "when installing" do |
90 | 118 | it "should preseed if a responsefile is provided" do |
91 | 119 | resource[:responsefile] = "/my/file" |
|
123 | 151 | provider.install |
124 | 152 | end |
125 | 153 |
|
126 | | - it "should select latest available version if range is specified" do |
127 | | - resource[:ensure] = '>60.0' |
128 | | - expect(provider).to receive(:aptget) do |*command| |
129 | | - expect(command[-1]).to eq("#{name}=72.0.1+build1-0ubuntu0.19.04.1") |
130 | | - end |
131 | | - expect(provider).to receive(:aptcache).with(:madison, name).and_return(<<-HERE) |
132 | | - #{name} | 72.0.1+build1-0ubuntu0.19.04.1 | http://ro.archive.ubuntu.com/ubuntu disco-updates/main amd64 Packages |
133 | | - #{name} | 72.0.1+build1-0ubuntu0.19.04.1 | http://security.ubuntu.com/ubuntu disco-security/main amd64 Packages |
134 | | - #{name} | 66.0.3+build1-0ubuntu1 | http://ro.archive.ubuntu.com/ubuntu disco/main amd64 Packages |
135 | | - HERE |
136 | | - expect(provider).to receive(:properties).and_return({:mark => :none}) |
137 | | - |
138 | | - provider.install |
139 | | - end |
140 | | - |
141 | | - it "should pass through ensure is no version can be selected" do |
142 | | - resource[:ensure] = '>74.0' |
143 | | - expect(provider).to receive(:aptget) do |*command| |
144 | | - expect(command[-1]).to eq("#{name}=>74.0") |
145 | | - end |
146 | | - expect(provider).to receive(:aptcache).with(:madison, name).and_return(<<-HERE) |
147 | | - #{name} | 72.0.1+build1-0ubuntu0.19.04.1 | http://ro.archive.ubuntu.com/ubuntu disco-updates/main amd64 Packages |
148 | | - #{name} | 72.0.1+build1-0ubuntu0.19.04.1 | http://security.ubuntu.com/ubuntu disco-security/main amd64 Packages |
149 | | - #{name} | 66.0.3+build1-0ubuntu1 | http://ro.archive.ubuntu.com/ubuntu disco/main amd64 Packages |
150 | | - HERE |
151 | | - expect(provider).to receive(:properties).and_return({:mark => :none}) |
152 | | - |
153 | | - provider.install |
154 | | - end |
155 | | - |
156 | 154 | it "should use --force-yes if a package version is specified" do |
157 | 155 | resource[:ensure] = '1.0' |
158 | 156 | expect(provider).to receive(:aptget) do |*command| |
|
0 commit comments