Files
puppet-manila/spec/unit/provider/manila_spec.rb
Takashi Kajinami 7e852c8e85 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: I36b60ea96e5a2d53f58094679bbd0f65b73c2b9f
2023-01-30 13:48:00 +09:00

49 lines
1.5 KiB
Ruby

require 'puppet'
require 'spec_helper'
require 'puppet/provider/manila'
require 'tempfile'
klass = Puppet::Provider::Manila
describe Puppet::Provider::Manila do
after :each do
klass.reset
end
describe 'when retrieving the auth credentials' do
it 'should fail if no auth params are passed and the manila config file does not have the expected contents' do
mock = {}
expect(Puppet::Util::IniConfig::File).to receive(:new).and_return(mock)
expect(mock).to receive(:read).with('/etc/manila/manila.conf')
expect do
klass.manila_credentials
end.to raise_error(Puppet::Error, /Manila types will not work/)
end
it 'should read conf file with all sections' do
creds_hash = {
'auth_url' => 'https://192.168.56.210:5000/v3/',
'project_name' => 'admin_tenant',
'username' => 'admin',
'password' => 'password',
'project_domain_name' => 'Default',
'user_domain_name' => 'Default',
}
mock = {
'keystone_authtoken' => {
'auth_url' => 'https://192.168.56.210:5000/v3/',
'project_name' => 'admin_tenant',
'username' => 'admin',
'password' => 'password',
}
}
expect(Puppet::Util::IniConfig::File).to receive(:new).and_return(mock)
expect(mock).to receive(:read).with('/etc/manila/manila.conf')
expect(klass.manila_credentials).to eq(creds_hash)
end
end
end