Skip to content

Commit

Permalink
update pureftpd::config::pgsql to use the common erb template + rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed Aug 6, 2013
1 parent f50f4db commit ab4cfb9
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 100 deletions.
42 changes: 41 additions & 1 deletion manifests/config/pgsql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,48 @@
#
# - implement template and variables for the pgsql config file
#
class pureftpd::config::pgsql (
$pgsqlserver = undef,
$pgsqlport = undef,
$pgsqluser = undef,
$pgsqlpassword = undef,
$pgsqldatabase = undef,
$pgsqlcrypt = undef,
$pgsqlgetpw = undef,
$pgsqlgetuid = undef,
$pgsqldefaultuid = undef,
$pgsqlgetgid = undef,
$pgsqldefaultgid = undef,
$pgsqlgetdir = undef,
$pgsqlgetqtafs = undef,
$pgsqlgetqtasz = undef,
$pgsqlgetratioul = undef,
$pgsqlgetratiodl = undef,
$pgsqlgetbandwidthul = undef,
$pgsqlgetbandwidthdl = undef,
) inherits pureftpd::params {

class pureftpd::config::pgsql inherits pureftpd::params {
# pure-ftpd-1.0.30/src/log_pgsql_p.h
$conf_options = [
'PGSQLServer',
'PGSQLPort',
'PGSQLUser',
'PGSQLPassword',
'PGSQLDatabase',
'PGSQLCrypt',
'PGSQLGetPW',
'PGSQLGetUID',
'PGSQLDefaultUID',
'PGSQLGetGID',
'PGSQLDefaultGID',
'PGSQLGetDir',
'PGSQLGetQTAFS',
'PGSQLGetQTASZ',
'PGSQLGetRatioUL',
'PGSQLGetRatioDL',
'PGSQLGetBandwidthUL',
'PGSQLGetBandwidthDL',
]

file { $pureftpd::params::pgsql_conf_path:
ensure => file,
Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
$mysql_conf_erb = 'redhat/pureftpd-mysql.conf.erb'
$mysql_conf_path = "${config_dir}/pureftpd-mysql.conf"

$pgsql_conf_erb = 'redhat/pureftpd-pgsql.conf.erb'
$pgsql_conf_erb = 'redhat/pure-ftpd.conf.erb'
$pgsql_conf_path = "${config_dir}/pureftpd-pgsql.conf"
}
default:{
Expand Down
63 changes: 63 additions & 0 deletions spec/classes/config_pgsql_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
require 'spec_helper'

test_options = [
'PGSQLServer',
'PGSQLPort',
'PGSQLUser',
'PGSQLPassword',
'PGSQLDatabase',
'PGSQLCrypt',
'PGSQLGetPW',
'PGSQLGetUID',
'PGSQLDefaultUID',
'PGSQLGetGID',
'PGSQLDefaultGID',
'PGSQLGetDir',
'PGSQLGetQTAFS',
'PGSQLGetQTASZ',
'PGSQLGetRatioUL',
'PGSQLGetRatioDL',
'PGSQLGetBandwidthUL',
'PGSQLGetBandwidthDL',
]

describe 'pureftpd::config::pgsql' do

shared_examples 'config' do |params, content|
let(:facts) {{ :osfamily=> 'RedHat' }}
let(:params) { params }

it do
should include_class('pureftpd::config::pgsql')
should contain_file('/etc/pure-ftpd/pureftpd-pgsql.conf') \
.with_ensure('file') \
.with_content(content)
end
end

all_params = {}
all_content = ''
value = 'xxx'

# accumutate all of the params and content strings as we test each individual
# option so we can use them for the next test
context 'one option at a time' do
test_options.each do |option|
params = {}
params[option.downcase.to_sym] = value
content = sprintf("%-19s %s\n", option, value)

all_params.merge!(params)
all_content += content

it_behaves_like 'config', params, content
end
end

# test all of the known options at once this works because the ordering of
# options values in the output file is fixed
context 'all options' do
it_behaves_like 'config', all_params, all_content
end

end
98 changes: 0 additions & 98 deletions templates/redhat/pureftpd-pgsql.conf.erb

This file was deleted.

0 comments on commit ab4cfb9

Please sign in to comment.