-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathpuppet_infra_upgrade_spec.rb
43 lines (37 loc) · 1.53 KB
/
puppet_infra_upgrade_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'spec_helper'
require_relative '../../../tasks/puppet_infra_upgrade'
describe PEAdm::Task::PuppetInfraUpgrade do
context 'replica' do
let(:upgrade) do
described_class.new('type' => 'replica',
'targets' => ['replica.example.com'],
'wait_until_connected_timeout' => 120)
end
it 'Returns when the command exits with an expected code' do
status_dbl_0 = double('Status', :exitstatus => 0)
status_dbl_11 = double('Status', :exitstatus => 11)
allow(STDOUT).to receive(:puts)
allow(upgrade).to receive(:wait_until_connected)
allow(Open3).to receive(:capture2e).and_return(['hello world', status_dbl_0])
expect(upgrade.execute!).to eq(nil)
allow(Open3).to receive(:capture2e).and_return(['hello world', status_dbl_11])
expect(upgrade.execute!).to eq(nil)
end
it 'Exits non-zero when the command exits with an unexpected code' do
status_dbl_1 = double('Status', :exitstatus => 1)
allow(STDOUT).to receive(:puts)
allow(upgrade).to receive(:wait_until_connected)
allow(Open3).to receive(:capture2e).and_return(['hello world', status_dbl_1])
expect { upgrade.execute! }.to raise_error(SystemExit) do |error|
expect(error.status).to eq(1)
end
end
end
context 'compiler' do
let(:upgrade) do
described_class.new('type' => 'compiler',
'targets' => ['replica.example.com'],
'wait_until_connected_timeout' => 120)
end
end
end