Replace mocha by rspec-mocks
puppetlabs_spec_helper recommends rspec-mocks instead of mocha[1] and
it uses rspec-mocks by default instead of mocha since v 5.0.0[2]
This is the prep work to adapt to that migration.
[1] https://github.com/puppetlabs/puppetlabs_spec_helper/#mock_with
[2] 493f0cbc1c
Closes-Bug: #2004135
Change-Id: I5baa93e0a994da7f3fafe79ce2a3e1d9232ce56e
This commit is contained in:
parent
9da8335992
commit
710b668f91
@ -13,6 +13,8 @@ RSpec.configure do |c|
|
||||
|
||||
c.module_path = File.join(fixture_path, 'modules')
|
||||
c.manifest_dir = File.join(fixture_path, 'manifests')
|
||||
|
||||
c.mock_with :rspec
|
||||
end
|
||||
|
||||
at_exit { RSpec::Puppet::Coverage.report! }
|
||||
|
@ -38,9 +38,9 @@ describe provider_class do
|
||||
describe 'managing qos' do
|
||||
describe '#create' do
|
||||
it 'creates a qos' do
|
||||
provider_class.expects(:openstack)
|
||||
expect(provider_class).to receive(:openstack)
|
||||
.with('volume qos', 'create', '--format', 'shell', ['--property', 'key1=value1', '--property', 'key2=value2', 'QoS_1'])
|
||||
.returns('id="e0df397a-72d5-4494-9e26-4ac37632ff04"
|
||||
.and_return('id="e0df397a-72d5-4494-9e26-4ac37632ff04"
|
||||
name="QoS_1"
|
||||
properties="key1=\'value1\', key2=\'value2\'"
|
||||
')
|
||||
@ -51,7 +51,7 @@ properties="key1=\'value1\', key2=\'value2\'"
|
||||
|
||||
describe '#destroy' do
|
||||
it 'destroys a qos' do
|
||||
provider_class.expects(:openstack)
|
||||
expect(provider_class).to receive(:openstack)
|
||||
.with('volume qos', 'delete', 'QoS_1')
|
||||
provider.destroy
|
||||
expect(provider.exists?).to be_falsey
|
||||
@ -60,9 +60,9 @@ properties="key1=\'value1\', key2=\'value2\'"
|
||||
|
||||
describe '#instances' do
|
||||
it 'finds qos' do
|
||||
provider_class.expects(:openstack)
|
||||
expect(provider_class).to receive(:openstack)
|
||||
.with('volume qos', 'list', '--quiet', '--format', 'csv', [])
|
||||
.returns('"ID","Name","Consumer","Associations","Specs"
|
||||
.and_return('"ID","Name","Consumer","Associations","Specs"
|
||||
"28b632e8-6694-4bba-bf68-67b19f619019","qos-1","front-end","my_type1, my_type2","read_iops=\'value1\', write_iops=\'value2\'"
|
||||
"4f992f69-14ec-4132-9313-55cc06a6f1f6","qos-2","both","",""
|
||||
')
|
||||
@ -82,9 +82,9 @@ properties="key1=\'value1\', key2=\'value2\'"
|
||||
#Test with python-openstackclient => 3.8.0 output (column header change from 'Specs' to 'Properties')
|
||||
describe '#instances' do
|
||||
it 'finds qos' do
|
||||
provider_class.expects(:openstack)
|
||||
expect(provider_class).to receive(:openstack)
|
||||
.with('volume qos', 'list', '--quiet', '--format', 'csv', [])
|
||||
.returns('"ID","Name","Consumer","Associations","Properties"
|
||||
.and_return('"ID","Name","Consumer","Associations","Properties"
|
||||
"28b632e8-6694-4bba-bf68-67b19f619019","qos-1","front-end","my_type1","read_iops=\'value1\'"
|
||||
')
|
||||
instances = provider_class.instances
|
||||
|
@ -15,8 +15,8 @@ describe Puppet::Provider::Cinder do
|
||||
|
||||
it 'should fail if no auth params are passed and the cinder config file does not have the expected contents' do
|
||||
mock = {}
|
||||
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
|
||||
mock.expects(:read).with('/etc/cinder/cinder.conf')
|
||||
expect(Puppet::Util::IniConfig::File).to receive(:new).and_return(mock)
|
||||
expect(mock).to receive(:read).with('/etc/cinder/cinder.conf')
|
||||
expect do
|
||||
klass.cinder_credentials
|
||||
end.to raise_error(Puppet::Error, /Cinder types will not work/)
|
||||
@ -39,8 +39,8 @@ describe Puppet::Provider::Cinder do
|
||||
'password' => 'password',
|
||||
}
|
||||
}
|
||||
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
|
||||
mock.expects(:read).with('/etc/cinder/cinder.conf')
|
||||
expect(Puppet::Util::IniConfig::File).to receive(:new).and_return(mock)
|
||||
expect(mock).to receive(:read).with('/etc/cinder/cinder.conf')
|
||||
expect(klass.cinder_credentials).to eq(creds_hash)
|
||||
end
|
||||
|
||||
|
@ -40,9 +40,9 @@ describe provider_class do
|
||||
describe 'managing type' do
|
||||
describe '#create' do
|
||||
it 'creates a type' do
|
||||
provider_class.expects(:openstack)
|
||||
expect(provider_class).to receive(:openstack)
|
||||
.with('volume type', 'create', '--format', 'shell', ['--property', 'key=value', '--property', 'new_key=a-new_value', '--property', 'multiattach="<is> True"', '--public', 'Backend_1'])
|
||||
.returns('id="90e19aff-1b35-4d60-9ee3-383c530275ab"
|
||||
.and_return('id="90e19aff-1b35-4d60-9ee3-383c530275ab"
|
||||
name="Backend_1"
|
||||
properties="key=\'value\', new_key=\'a-new_value\', multiattach=\'<is> True\'"
|
||||
is_public="True"
|
||||
@ -55,7 +55,7 @@ access_project_ids=""
|
||||
|
||||
describe '#destroy' do
|
||||
it 'destroys a type' do
|
||||
provider_class.expects(:openstack)
|
||||
expect(provider_class).to receive(:openstack)
|
||||
.with('volume type', 'delete', 'Backend_1')
|
||||
provider.destroy
|
||||
expect(provider.exists?).to be_falsey
|
||||
@ -64,15 +64,15 @@ access_project_ids=""
|
||||
|
||||
describe '#instances' do
|
||||
it 'finds types' do
|
||||
provider_class.expects(:openstack)
|
||||
expect(provider_class).to receive(:openstack)
|
||||
.with('volume type', 'list', '--quiet', '--format', 'csv', '--long')
|
||||
.returns('"ID","Name","Is Public","Properties"
|
||||
.and_return('"ID","Name","Is Public","Properties"
|
||||
"28b632e8-6694-4bba-bf68-67b19f619019","type-1","True","key1=\'value1\'"
|
||||
"4f992f69-14ec-4132-9313-55cc06a6f1f6","type-2","False","key2=\'value2\'"
|
||||
')
|
||||
provider_class.expects(:openstack)
|
||||
expect(provider_class).to receive(:openstack)
|
||||
.with('volume type', 'show', '--format', 'shell', '4f992f69-14ec-4132-9313-55cc06a6f1f6')
|
||||
.returns('
|
||||
.and_return('
|
||||
id="4f992f69-14ec-4132-9313-55cc06a6f1f6"
|
||||
name="type-2"
|
||||
properties="key2=\'value2\'"
|
||||
@ -91,15 +91,15 @@ access_project_ids="54f4d231201b4944a5fa4587a09bda23, 54f4d231201b4944a5fa4587a0
|
||||
end
|
||||
|
||||
it 'finds types with a Properties hash' do
|
||||
provider_class.expects(:openstack)
|
||||
expect(provider_class).to receive(:openstack)
|
||||
.with('volume type', 'list', '--quiet', '--format', 'csv', '--long')
|
||||
.returns('"ID","Name","Is Public","Properties"
|
||||
.and_return('"ID","Name","Is Public","Properties"
|
||||
"28b632e8-6694-4bba-bf68-67b19f619019","type-1","True","{\'key1\': \'value1\'}"
|
||||
"4f992f69-14ec-4132-9313-55cc06a6f1f6","type-2","False","{\'key2\': \'value2\'}"
|
||||
')
|
||||
provider_class.expects(:openstack)
|
||||
expect(provider_class).to receive(:openstack)
|
||||
.with('volume type', 'show', '--format', 'shell', '4f992f69-14ec-4132-9313-55cc06a6f1f6')
|
||||
.returns('
|
||||
.and_return('
|
||||
id="4f992f69-14ec-4132-9313-55cc06a6f1f6"
|
||||
name="type-2"
|
||||
properties="key2=\'value2\'"
|
||||
|
Loading…
Reference in New Issue
Block a user