Skip to content

Commit

Permalink
refactor replset provider test
Browse files Browse the repository at this point in the history
  • Loading branch information
DeathBorn committed Aug 2, 2018
1 parent fe6bd6a commit 7c68601
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions spec/unit/puppet/provider/mongodb_replset/mongodb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ensure: :present,
name: 'rs_test',
members: valid_members,
settings: {},
provider: :mongo
)
end
Expand All @@ -37,23 +38,11 @@
end

# rubocop:disable RSpec/MessageSpies
it 'creates a replicaset' do
allow(provider.class).to receive(:replset_properties)
allow(provider).to receive(:alive_members).and_return(valid_members)
allow(provider).to receive(:master_host).and_return(false)
expect(provider).to receive(:rs_initiate).with('{ _id: "rs_test", members: [ { _id: 0, host: "mongo1:27017" },{ _id: 1, host: "mongo2:27017" },{ _id: 2, host: "mongo3:27017" } ] }', 'mongo1:27017').and_return('info' => 'Config now saved locally. Should come online in about a minute.', 'ok' => 1)
allow(provider).to receive(:db_ismaster).and_return('{"ismaster" : true}')
provider.create
provider.flush
end

it 'creates a replicaset with arbiter' do
allow(provider.class).to receive(:replset_properties)
allow(provider).to receive(:alive_members).and_return(valid_members)
allow(provider).to receive(:master_host).and_return(false)
allow(provider).to receive(:rs_arbiter).and_return('mongo3:27017')
expect(provider).to receive('rs_initiate').with('{ _id: "rs_test", members: [ { _id: 0, host: "mongo1:27017" },{ _id: 1, host: "mongo2:27017" },{ _id: 2, host: "mongo3:27017", arbiterOnly: "true" } ] }', 'mongo1:27017').and_return('info' => 'Config now saved locally. Should come online in about a minute.',
'ok' => 1)
expect(provider).to receive(:rs_initiate).with('{"_id":"rs_test","members":[{"_id": 0,"host":"mongo1:27017"},{"_id":1,"host":"mongo2:27017" },{"_id":2,"host":"mongo3:27017"}],"settings": {}}', 'mongo1:27017').and_return('info' => 'Config now saved locally. Should come online in about a minute.', 'ok' => 1)
allow(provider).to receive(:db_ismaster).and_return('{"ismaster" : true}')
provider.create
provider.flush
Expand Down

0 comments on commit 7c68601

Please sign in to comment.