Skip to content

(FM-3940) Fix specs - Puppet 4.x validation errors #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions spec/acceptance/sqlserver_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,35 +106,5 @@ def ensure_sqlserver_instance(host,inst_name, ensure_val = 'present')
expect(r.stderr).not_to match(/Error/i)
end
end

it "Negative test: sqlserver::config without admin_user" do
pp = <<-MANIFEST
sqlserver::config{'#{inst_name}':
admin_pass => '#{@admin_pass}',
instance_name => '#{inst_name}',
}
sqlserver::database{'#{db_name}':
instance => '#{inst_name}',
}
MANIFEST
apply_manifest_on(host, pp, {:acceptable_exit_codes => [0,1]}) do |r|
expect(r.stderr).to match(/Error: Must pass admin_user to Sqlserver/)
end
end

it "Negative test: sqlserver::config without admin_pass" do
pp = <<-MANIFEST
sqlserver::config{'#{inst_name}':
admin_user => '#{@admin_user}',
instance_name => '#{inst_name}',
}
sqlserver::database{'#{db_name}':
instance => '#{inst_name}',
}
MANIFEST
apply_manifest_on(host, pp, {:acceptable_exit_codes => [0,1]}) do |r|
expect(r.stderr).to match(/Error: Must pass admin_pass to Sqlserver/)
end
end
end
end
49 changes: 44 additions & 5 deletions spec/defines/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,55 @@

RSpec.describe 'sqlserver::config', :type => :define do
let(:title) { 'MSSQLSERVER' }
let(:params) { {
:instance_name => 'MSSQLSERVER',
:admin_user => 'sa',
:admin_pass => 'Pupp3t1@',
} }
let(:facts) { {:osfamily => 'windows', :platform => :windows, :puppet_vardir => 'C:/ProgramData/PuppetLabs/puppet/var'} }

describe 'compile' do
let(:params) { {
:instance_name => 'MSSQLSERVER',
:admin_user => 'sa',
:admin_pass => 'Pupp3t1@',
} }

it {
should_not contain_file('C:/ProgramData/PuppetLabs/puppet/var/cache/sqlserver/.MSSQLSERVER.cfg')
should_not contain_file('C:/ProgramData/PuppetLabs/puppet/var/cache/sqlserver')
}
end

context 'without admin_pass' do
let(:params) { {
:instance_name => 'MSSQLSERVER',
:admin_user => 'sa',
} }

if Puppet.version < '4.0.0'
let(:error_message) { /Must pass admin_pass to Sqlserver::Config/ }
else
let(:error_message) { /expects a value for parameter 'admin_pass'/ }
end

it {
should_not compile
expect { catalogue }.to raise_error(Puppet::Error, error_message)
}
end

context 'without admin_user' do
let(:params) { {
:instance_name => 'MSSQLSERVER',
:admin_pass => 'Pupp3t1@',
} }


if Puppet.version < '4.0.0'
let(:error_message) { /Must pass admin_user to Sqlserver::Config/ }
else
let(:error_message) { /expects a value for parameter 'admin_user'/ }
end

it {
should_not compile
expect { catalogue }.to raise_error(Puppet::Error, error_message)
}
end
end
6 changes: 5 additions & 1 deletion spec/defines/login/permissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
} }
let(:raise_error_check) { 'Login must be between 1 and 128 characters' }
describe 'missing' do
let(:raise_error_check) { 'Must pass login to Sqlserver::Login::Permissions[myTitle]' }
if Puppet.version < '4.0.0'
let(:raise_error_check) { 'Must pass login to Sqlserver::Login::Permissions[myTitle]' }
else
let(:raise_error_check) { "expects a value for parameter 'login'" }
end
it_behaves_like 'validation error'
end
describe 'empty' do
Expand Down
7 changes: 6 additions & 1 deletion spec/defines/user/permissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
} }
let(:raise_error_check) { 'User must be between 1 and 128 characters' }
describe 'missing' do
let(:raise_error_check) { 'Must pass user to Sqlserver::User::Permissions[myTitle]' }
if Puppet.version < '4.0.0'
let(:raise_error_check) { 'Must pass user to Sqlserver::User::Permissions[myTitle]' }
else
let(:raise_error_check) { "expects a value for parameter 'user'" }
end

it_behaves_like 'validation error'
end
describe 'empty' do
Expand Down