-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathinstall_spec.rb
99 lines (86 loc) · 2.98 KB
/
install_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
require 'spec_helper'
describe 'peadm::subplans::install' do
# Include the BoltSpec library functions
include BoltSpec::Plans
before(:each) do
allow_any_task
allow_any_plan
allow_any_command
allow_task('peadm::precheck').return_for_targets(
'primary' => {
'hostname' => 'primary',
'platform' => 'el-7.11-x86_64',
},
'compiler1' => {
'hostname' => 'compiler1',
'platform' => 'el-7.11-x86_64',
},
'compiler2' => {
'hostname' => 'compiler2',
'platform' => 'el-7.11-x86_64',
},
)
#########
## <🤮>
# rubocop:disable AnyInstance
allow(Tempfile).to receive(:new).and_call_original
allow(Pathname).to receive(:new).and_call_original
allow(Puppet::FileSystem).to receive(:exist?).and_call_original
allow_any_instance_of(BoltSpec::Plans::MockExecutor).to receive(:module_file_id).and_call_original
mockfile = instance_double('Tempfile', path: '/mock', write: nil, flush: nil, close: nil, unlink: nil)
mockpath = instance_double('Pathname', absolute?: true)
allow(Tempfile).to receive(:new).with('peadm').and_return(mockfile)
allow(Pathname).to receive(:new).with('/mock').and_return(mockpath)
allow(Puppet::FileSystem).to receive(:exist?).with('/mock').and_return(true)
allow_any_instance_of(BoltSpec::Plans::MockExecutor).to receive(:module_file_id).with('/mock').and_return('/mock')
allow_upload('/mock')
# rubocop:enable AnyInstance
## </🤮>
##########
end
it 'minimum variables to run' do
params = {
'primary_host' => 'primary',
'console_password' => 'puppetLabs123!',
'version' => '2019.8.12',
}
expect(run_plan('peadm::subplans::install', params)).to be_ok
end
it 'installs 2023.4 without r10k_known_hosts' do
params = {
'primary_host' => 'primary',
'console_password' => 'puppetLabs123!',
'version' => '2023.4.0',
'r10k_remote' => '[email protected]:puppetlabs/nothing',
'r10k_private_key_content' => '-----BEGINfoo',
}
expect(run_plan('peadm::subplans::install', params)).to be_ok
end
it 'installs 2023.4+ with r10k_private_key and r10k_known_hosts' do
params = {
'primary_host' => 'primary',
'console_password' => 'puppetLabs123!',
'version' => '2023.4.0',
'r10k_remote' => '[email protected]:puppetlabs/nothing',
'r10k_private_key_content' => '-----BEGINfoo',
'r10k_known_hosts' => [
{
'name' => 'test',
'type' => 'key-type',
'key' => 'abcdef',
},
],
'permit_unsafe_versions' => true,
}
expect(run_plan('peadm::subplans::install', params)).to be_ok
end
it 'installs 2023.8.0 with legacy compilers' do
params = {
'primary_host' => 'primary',
'console_password' => 'puppetLabs123!',
'version' => '2023.8.0',
'legacy_compilers' => ['compiler1', 'compiler2'],
}
expect(run_plan('peadm::subplans::install', params)).to be_ok
end
end