Skip to content

Commit 5584da4

Browse files
committed
(MODULES-11365) Updates override_facts calls
Commit 4c7b664 added the override_facts method to help merge hashes of structured facts. However, the rspec tests that used this method mistakenly passed a hash of facts into the method instead of using keyword arguments. This commit updates override_facts calls in rpsec tests to correctly use keyword arguments.
1 parent 98261fc commit 5584da4

6 files changed

+27
-208
lines changed

spec/classes/puppet_agent_osfamily_aix_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
let(:common_facts) do
55
{
66
clientcert: 'foo.example.vm',
7-
is_pe: true,
7+
is_pe: true,
88
os: {
99
architecture: 'PowerPC_POWER7',
1010
family: 'AIX',
1111
name: 'AIX',
1212
},
13-
platform_tag: 'aix-7.2-power',
14-
servername: 'master.example.vm',
13+
platform_tag: 'aix-7.2-power',
14+
servername: 'master.example.vm',
1515
}
1616
end
1717

@@ -212,7 +212,7 @@
212212

213213
context 'not AIX' do
214214
let(:facts) do
215-
override_facts(common_facts, { os: { name: 'not-AIX', }, })
215+
override_facts(common_facts, os: { name: 'not-AIX' })
216216
end
217217

218218
it { expect { catalogue }.to raise_error(%r{not supported}) }

spec/classes/puppet_agent_osfamily_darwin_spec.rb

Lines changed: 8 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,13 @@
4141
describe 'supported environment' do
4242
let(:params) { { package_version: package_version } }
4343

44-
context 'when running a supported OSX' do
44+
context 'when running a supported macOS' do
4545
['osx-10.15-x86_64', 'osx-11-x86_64', 'osx-12-x86_64'].each do |tag|
4646
context "on #{tag} with no aio_version" do
4747
let(:osmajor) { tag.split('-')[1] }
4848

4949
let(:facts) do
50-
override_facts(facts,
51-
{
52-
aio_agent_version: '1.10.99',
53-
is_pe: true,
54-
os: {
55-
macosx: {
56-
version: {
57-
major: osmajor,
58-
},
59-
},
60-
},
61-
platform_tag: tag,
62-
})
50+
override_facts(facts, aio_agent_version: '1.10.99', is_pe: true, os: { macosx: { version: { major: osmajor, }, }, }, platform_tag: tag)
6351
end
6452

6553
it { is_expected.to compile.with_all_deps }
@@ -95,18 +83,7 @@
9583
}
9684
end
9785
let(:facts) do
98-
override_facts(facts, {
99-
aio_agent_version: '1.10.99',
100-
is_pe: true,
101-
os: {
102-
macosx: {
103-
version: {
104-
major: '10.13',
105-
},
106-
},
107-
},
108-
platform_tag: 'osx-10.13-x86_64',
109-
})
86+
override_facts(facts, aio_agent_version: '1.10.99', is_pe: true, os: { macosx: { version: { major: '10.13', }, }, }, platform_tag: 'osx-10.13-x86_64')
11087
end
11188

11289
it { is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-5.10.100.1-1.osx10.13.dmg').with_source('https://fake-pe-master.com/packages/2000.0.0/osx-10.13-x86_64/puppet-agent-5.10.100.1-1.osx10.13.dmg') }
@@ -119,69 +96,33 @@
11996
}
12097
end
12198
let(:facts) do
122-
override_facts(facts, {
123-
aio_agent_version: '1.10.99',
124-
is_pe: true,
125-
os: {
126-
macosx: {
127-
version: {
128-
major: '10.13',
129-
},
130-
},
131-
},
132-
platform_tag: 'osx-10.13-x86_64',
133-
serverversion: '5.10.200',
134-
})
99+
override_facts(facts, aio_agent_version: '1.10.99', is_pe: true, os: { macosx: { version: { major: '10.13', }, }, }, platform_tag: 'osx-10.13-x86_64', serverversion: '5.10.200')
135100
end
136101

137102
it { is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-5.10.200-1.osx10.13.dmg').with_source('puppet:///pe_packages/2000.0.0/osx-10.13-x86_64/puppet-agent-5.10.200-1.osx10.13.dmg') }
138103
end
139104

140-
describe 'when using package_version auto with MacOS 11(two numbers version productversion)' do
105+
describe 'when using package_version auto with macOS 11 (two numbers version productversion)' do
141106
let(:params) do
142107
{
143108
package_version: 'auto',
144109
}
145110
end
146111
let(:facts) do
147-
override_facts(facts, {
148-
aio_agent_version: '1.10.99',
149-
is_pe: true,
150-
os: {
151-
macosx: {
152-
version: {
153-
major: '11.2',
154-
},
155-
},
156-
},
157-
platform_tag: 'osx-11-x86_64',
158-
serverversion: '5.10.200'
159-
})
112+
override_facts(facts, aio_agent_version: '1.10.99', is_pe: true, os: { macosx: { version: { major: '11.2', }, }, }, platform_tag: 'osx-11-x86_64', serverversion: '5.10.200')
160113
end
161114

162115
it { is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-5.10.200-1.osx11.dmg').with_source('puppet:///pe_packages/2000.0.0/osx-11-x86_64/puppet-agent-5.10.200-1.osx11.dmg') }
163116
end
164117

165-
describe 'when using package_version auto with MacOS 11(one number version productversion)' do
118+
describe 'when using package_version auto with macOS 11 (one number version productversion)' do
166119
let(:params) do
167120
{
168121
package_version: 'auto',
169122
}
170123
end
171124
let(:facts) do
172-
override_facts(facts, {
173-
aio_agent_version: '1.10.99',
174-
is_pe: true,
175-
os: {
176-
macosx: {
177-
version: {
178-
major: '11',
179-
},
180-
},
181-
},
182-
platform_tag: 'osx-11-x86_64',
183-
serverversion: '5.10.200',
184-
})
125+
override_facts(facts, aio_agent_version: '1.10.99', is_pe: true, os: { macosx: { version: { major: '11', }, }, }, platform_tag: 'osx-11-x86_64', serverversion: '5.10.200')
185126
end
186127

187128
it { is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-5.10.200-1.osx11.dmg').with_source('puppet:///pe_packages/2000.0.0/osx-11-x86_64/puppet-agent-5.10.200-1.osx11.dmg') }

spec/classes/puppet_agent_osfamily_debian_spec.rb

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@
4545
end
4646

4747
let(:facts) do
48-
override_facts(facts, {
49-
is_pe: true,
50-
platform_tag: 'debian-7-x86_64',
51-
})
48+
override_facts(facts, is_pe: true, platform_tag: 'debian-7-x86_64')
5249
end
5350

5451
context 'when managing PE debian apt repo' do
@@ -96,19 +93,7 @@
9693

9794
context 'focal' do
9895
let(:facts) do
99-
override_facts(facts, {
100-
is_pe: true,
101-
os: {
102-
distro: {
103-
codename: 'focal',
104-
},
105-
name: 'Ubuntu',
106-
release: {
107-
full: '20.04',
108-
},
109-
},
110-
platform_tag: 'ubuntu-2004-x86_64',
111-
})
96+
override_facts(facts, is_pe: true, os: { distro: { codename: 'focal', }, name: 'Ubuntu', release: { full: '20.04', }, }, platform_tag: 'ubuntu-2004-x86_64')
11297
end
11398

11499
context 'when managing debian focal apt repo' do

spec/classes/puppet_agent_osfamily_redhat_spec.rb

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,7 @@
2424
[['Rocky', 'el/8', 8], ['AlmaLinux', 'el/8', 8], ['Fedora', 'fedora/f36', 36], ['CentOS', 'el/7', 7], ['Amazon', 'el/6', 2017], ['Amazon', 'el/7', 2]].each do |os, urlbit, osmajor|
2525
context "with #{os} and #{urlbit}" do
2626
let(:facts) do
27-
override_facts(super(), {
28-
os: {
29-
name: os,
30-
release: {
31-
major: osmajor,
32-
},
33-
},
34-
})
27+
override_facts(super(), os: { name: os, release: { major: osmajor, }, })
3528
end
3629

3730
script = <<-SCRIPT
@@ -182,16 +175,7 @@
182175
end
183176

184177
let(:facts) do
185-
override_facts(super(), {
186-
is_pe: true,
187-
os: {
188-
name: os,
189-
release: {
190-
major: osmajor,
191-
},
192-
},
193-
platform_tag: tag,
194-
})
178+
override_facts(super(), is_pe: true, os: { name: os, release: { major: osmajor, }, }, platform_tag: tag)
195179
end
196180

197181
context 'when using a custom source' do

spec/classes/puppet_agent_osfamily_solaris_spec.rb

Lines changed: 8 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,7 @@ def install_script(ver, arch)
118118

119119
context 'when Solaris 11 i386 and a custom source' do
120120
let(:facts) do
121-
override_facts(facts, {
122-
is_pe: true,
123-
os: {
124-
release: {
125-
major: '11',
126-
},
127-
},
128-
platform_tag: 'solaris-11-i386',
129-
})
121+
override_facts(facts, is_pe: true, os: { release: { major: '11', }, }, platform_tag: 'solaris-11-i386')
130122
end
131123
let(:params) do
132124
{
@@ -146,15 +138,7 @@ def install_script(ver, arch)
146138

147139
context 'when Solaris 11 i386' do
148140
let(:facts) do
149-
override_facts(facts, {
150-
is_pe: true,
151-
os: {
152-
release: {
153-
major: '11',
154-
},
155-
},
156-
platform_tag: 'solaris-11-i386',
157-
})
141+
override_facts(facts, is_pe: true, os: { release: { major: '11', }, }, platform_tag: 'solaris-11-i386')
158142
end
159143

160144
it { is_expected.to compile.with_all_deps }
@@ -211,16 +195,7 @@ def install_script(ver, arch)
211195

212196
context 'when Solaris 11 sparc sun4u' do
213197
let(:facts) do
214-
override_facts(facts, {
215-
is_pe: true,
216-
os: {
217-
architecture: 'sun4u',
218-
release: {
219-
major: '11',
220-
},
221-
},
222-
platform_tag: 'solaris-11-sparc',
223-
})
198+
override_facts(facts, is_pe: true, os: { architecture: 'sun4u', release: { major: '11', }, }, platform_tag: 'solaris-11-sparc')
224199
end
225200

226201
it { is_expected.to compile.with_all_deps }
@@ -276,15 +251,7 @@ def install_script(ver, arch)
276251

277252
context 'when Solaris 10 i386 and a custom source' do
278253
let(:facts) do
279-
override_facts(facts, {
280-
is_pe: true,
281-
os: {
282-
release: {
283-
major: '10',
284-
},
285-
},
286-
platform_tag: 'solaris-10-i386',
287-
})
254+
override_facts(facts, is_pe: true, os: { release: { major: '10', }, }, platform_tag: 'solaris-10-i386')
288255
end
289256
let(:params) do
290257
{
@@ -304,15 +271,7 @@ def install_script(ver, arch)
304271

305272
context 'when Solaris 10 i386' do
306273
let(:facts) do
307-
override_facts(facts, {
308-
is_pe: true,
309-
os: {
310-
release: {
311-
major: '10',
312-
},
313-
},
314-
platform_tag: 'solaris-10-i386',
315-
})
274+
override_facts(facts, is_pe: true, os: { release: { major: '10', }, }, platform_tag: 'solaris-10-i386')
316275
end
317276

318277
it { is_expected.to compile.with_all_deps }
@@ -337,16 +296,7 @@ def install_script(ver, arch)
337296

338297
context 'with older aio_agent_version' do
339298
let(:facts) do
340-
override_facts(facts, {
341-
aio_agent_version: '1.0.0',
342-
is_pe: true,
343-
os: {
344-
release: {
345-
major: '10',
346-
},
347-
},
348-
platform_tag: 'solaris-10-i386',
349-
})
299+
override_facts(facts, aio_agent_version: '1.0.0', is_pe: true, os: { release: { major: '10', }, }, platform_tag: 'solaris-10-i386')
350300
end
351301

352302
it do
@@ -374,16 +324,7 @@ def install_script(ver, arch)
374324
end
375325

376326
let(:facts) do
377-
override_facts(facts, {
378-
is_pe: true,
379-
os: {
380-
architecture: 'sun4u',
381-
release: {
382-
major: '10',
383-
},
384-
},
385-
platform_tag: 'solaris-10-sparc',
386-
})
327+
override_facts(facts, is_pe: true, os: { architecture: 'sun4u', release: { major: '10', }, }, platform_tag: 'solaris-10-sparc')
387328
end
388329

389330
it { is_expected.to compile.with_all_deps }
@@ -407,17 +348,7 @@ def install_script(ver, arch)
407348

408349
context 'with older aio_agent_version' do
409350
let(:facts) do
410-
override_facts(facts, {
411-
aio_agent_version: '1.0.0',
412-
is_pe: true,
413-
os: {
414-
architecture: 'sun4u',
415-
release: {
416-
major: '10',
417-
},
418-
},
419-
platform_tag: 'solaris-10-sparc',
420-
})
351+
override_facts(facts, aio_agent_version: '1.0.0', is_pe: true, os: { architecture: 'sun4u', release: { major: '10', }, }, platform_tag: 'solaris-10-sparc')
421352
end
422353

423354
it do

0 commit comments

Comments
 (0)