Skip to content

Commit e18307f

Browse files
author
Johan De Wit
committed
fix unit tests
1 parent 8b2024c commit e18307f

File tree

6 files changed

+27
-37
lines changed

6 files changed

+27
-37
lines changed

spec/classes/client_spec.rb

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@
99

1010
context 'with defaults' do
1111
it { is_expected.to compile.with_all_deps }
12-
13-
if facts[:os]['release']['major'] =~ %r{(10)}
14-
it { is_expected.to create_package('mongodb_client').with_ensure('4.4.8') }
15-
else
16-
it { is_expected.to create_package('mongodb_client').with_ensure('present') }
17-
end
12+
it { is_expected.to create_package('mongodb_client').with_ensure('present') }
1813
end
1914

2015
context 'with manage_package' do
@@ -23,12 +18,7 @@
2318
end
2419

2520
it { is_expected.to compile.with_all_deps }
26-
27-
if facts[:os]['release']['major'] =~ %r{(10)}
28-
it { is_expected.to create_package('mongodb_client').with_ensure('4.4.8').with_name('mongodb-org-shell').with_tag('mongodb_package') }
29-
else
30-
it { is_expected.to create_package('mongodb_client').with_ensure('present').with_name('mongodb-org-shell').with_tag('mongodb_package') }
31-
end
21+
it { is_expected.to create_package('mongodb_client').with_ensure('present').with_name('mongodb-mongosh').with_tag('mongodb_package') }
3222
end
3323
end
3424
end

spec/classes/mongos_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
it { is_expected.to contain_class('mongodb::mongos::install') }
2828

2929
if facts[:os]['release']['major'] =~ %r{(10)}
30-
it { is_expected.to contain_package('mongodb_mongos').with_ensure('4.4.8').with_name(package_name).with_tag('mongodb_package') }
30+
it { is_expected.to contain_package('mongodb_mongos').with_ensure('6.0').with_name(package_name).with_tag('mongodb_package') }
3131
else
32-
it { is_expected.to contain_package('mongodb_mongos').with_ensure('present').with_name(package_name).with_tag('mongodb_package') }
32+
it { is_expected.to contain_package('mongodb_mongos').with_ensure('6.0').with_name(package_name).with_tag('mongodb_package') }
3333
end
3434

3535
# config
@@ -92,9 +92,9 @@
9292
it { is_expected.to compile.with_all_deps }
9393

9494
if facts[:os]['release']['major'] =~ %r{(10)}
95-
it { is_expected.to contain_package('mongodb_mongos').with_name('mongo-foo').with_ensure('4.4.8').with_tag('mongodb_package') }
95+
it { is_expected.to contain_package('mongodb_mongos').with_name('mongo-foo').with_ensure('6.0').with_tag('mongodb_package') }
9696
else
97-
it { is_expected.to contain_package('mongodb_mongos').with_name('mongo-foo').with_ensure('present').with_tag('mongodb_package') }
97+
it { is_expected.to contain_package('mongodb_mongos').with_name('mongo-foo').with_ensure('6.0').with_tag('mongodb_package') }
9898
end
9999
end
100100

spec/classes/repo_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
describe 'with version set' do
1717
let :params do
1818
{
19-
version: '3.6.1'
19+
version: '6.0.7'
2020
}
2121
end
2222

@@ -26,14 +26,14 @@
2626

2727
it do
2828
is_expected.to contain_yumrepo('mongodb').
29-
with_baseurl('https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/$basearch/')
29+
with_baseurl('https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/$basearch/')
3030
end
3131
when 'Suse'
3232
it { is_expected.to contain_class('mongodb::repo::zypper') }
3333

3434
it do
3535
is_expected.to contain_zypprepo('mongodb').
36-
with_baseurl('https://repo.mongodb.org/zypper/suse/$releasever_major/mongodb-org/3.6/$basearch/')
36+
with_baseurl('https://repo.mongodb.org/zypper/suse/$releasever_major/mongodb-org/6.0/$basearch/')
3737
end
3838
when 'Debian'
3939
it { is_expected.to contain_class('mongodb::repo::apt') }
@@ -43,13 +43,13 @@
4343
it do
4444
is_expected.to contain_apt__source('mongodb').
4545
with_location('https://repo.mongodb.org/apt/debian').
46-
with_release("#{facts[:lsbdistcodename]}/mongodb-org/3.6")
46+
with_release("#{facts[:lsbdistcodename]}/mongodb-org/6.0")
4747
end
4848
when 'Ubuntu'
4949
it do
5050
is_expected.to contain_apt__source('mongodb').
5151
with_location('https://repo.mongodb.org/apt/ubuntu').
52-
with_release("#{facts[:lsbdistcodename]}/mongodb-org/3.6")
52+
with_release("#{facts[:lsbdistcodename]}/mongodb-org/6.0")
5353
end
5454
end
5555
else
@@ -60,7 +60,7 @@
6060
describe 'with proxy' do
6161
let :params do
6262
{
63-
version: '3.6.1',
63+
version: '6.0.7',
6464
proxy: 'http://proxy-server:8080',
6565
proxy_username: 'proxyuser1',
6666
proxy_password: 'proxypassword1'

spec/classes/server_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@
4747
it_behaves_like 'server classes'
4848

4949
if facts[:os]['family'] == 'RedHat' || facts[:os]['family'] == 'Suse'
50-
it { is_expected.to contain_package('mongodb_server').with_ensure('present').with_name('mongodb-org-server').with_tag('mongodb_package') }
50+
it { is_expected.to contain_package('mongodb_server').with_ensure('6.0').with_name('mongodb-org-server').with_tag('mongodb_package') }
5151
elsif facts[:os]['release']['major'] =~ %r{(10)}
52-
it { is_expected.to contain_package('mongodb_server').with_ensure('4.4.8').with_name('mongodb-org-server').with_tag('mongodb_package') }
52+
it { is_expected.to contain_package('mongodb_server').with_ensure('6.0').with_name('mongodb-org-server').with_tag('mongodb_package') }
5353
else
54-
it { is_expected.to contain_package('mongodb_server').with_ensure('present').with_name('mongodb-server').with_tag('mongodb_package') }
54+
it { is_expected.to contain_package('mongodb_server').with_ensure('6.0').with_name('mongodb-server').with_tag('mongodb_package') }
5555
end
5656

5757
it do
5858
is_expected.to contain_file(config_file).
5959
with_mode('0644').
6060
with_owner('root').
6161
with_group('root').
62-
with_content(%r{^storage\.dbPath: /var/lib/mongodb$}).
62+
with_content(%r{^storage\.dbPath: /var/lib/mongo$}).
6363
with_content(%r{^net\.bindIp: 127\.0\.0\.1$}).
6464
with_content(%r{^systemLog\.logAppend: true$}).
6565
with_content(%r{^systemLog\.path: #{log_path}$})
@@ -304,10 +304,10 @@
304304

305305
it do
306306
is_expected.to contain_exec('fix dbpath permissions').
307-
with_command('chown -R foo:bar /var/lib/mongodb').
307+
with_command('chown -R foo:bar /var/lib/mongo').
308308
with_path(['/usr/bin', '/bin']).
309-
with_onlyif("find /var/lib/mongodb -not -user foo -o -not -group bar -print -quit | grep -q '.*'").
310-
that_subscribes_to('File[/var/lib/mongodb]')
309+
with_onlyif("find /var/lib/mongo -not -user foo -o -not -group bar -print -quit | grep -q '.*'").
310+
that_subscribes_to('File[/var/lib/mongo]')
311311
end
312312
end
313313

spec/unit/mongodb_version_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
describe 'mongodb_version' do
1111
context 'with value' do
1212
before do
13-
allow(Facter::Core::Execution).to receive(:which).with('mongo').and_return(true)
14-
allow(Facter::Core::Execution).to receive(:execute).with('mongo --version 2>&1').and_return('MongoDB shell version: 3.2.1')
13+
allow(Facter::Core::Execution).to receive(:which).with('mongod').and_return(true)
14+
allow(Facter::Core::Execution).to receive(:execute).with('mongod --version 2>&1').and_return('db version v6.0.7')
1515
end
1616

1717
it {
18-
expect(Facter.fact(:mongodb_version).value).to eq('3.2.1')
18+
expect(Facter.fact(:mongodb_version).value).to eq('6.0.7')
1919
}
2020
end
2121
end

spec/unit/puppet/provider/mongodb_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414

1515
describe 'mongo version detection' do
1616
v = {
17-
'2.6.x' => { '26' => true, '4' => false, '5' => false },
18-
'4.x.x' => { '26' => false, '4' => true, '5' => false },
19-
'5.x.x' => { '26' => false, '4' => false, '5' => true },
20-
'x.x.x' => { '26' => false, '4' => false, '5' => false }
17+
'4.x.x' => { '4' => true, '5' => false, '6' => false },
18+
'5.x.x' => { '4' => false, '5' => true, '6' => false },
19+
'6.x.x' => { '4' => false, '5' => false, '6' => true },
20+
'x.x.x' => { '4' => false, '5' => false, '6' => false }
2121
}
2222

2323
v.each do |key, results|
2424
it "version detection for [#{key}]" do
2525
allow(provider_class).to receive(:mongo_eval).with('db.version()').and_return(key)
26-
expect(provider_class.mongo_26?).to be results['26']
2726
expect(provider_class.mongo_4?).to be results['4']
2827
expect(provider_class.mongo_5?).to be results['5']
28+
expect(provider_class.mongo_6?).to be results['6']
2929
end
3030
end
3131
end

0 commit comments

Comments
 (0)