Skip to content

Commit

Permalink
update pureftpd::config::mysql 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 ab4cfb9 commit df44134
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 132 deletions.
49 changes: 48 additions & 1 deletion manifests/config/mysql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,54 @@
# - implement template and variables for the mysql config file
#

class pureftpd::config::mysql inherits pureftpd::params {
class pureftpd::config::mysql (
$mysqlserver = undef,
$mysqlport = undef,
$mysqlsocket = undef,
$mysqluser = undef,
$mysqlpassword = undef,
$mysqldatabase = undef,
$mysqlcrypt = undef,
$mysqltransactions = undef,
$mysqlgetpw = undef,
$mysqlgetuid = undef,
$mysqldefaultuid = undef,
$mysqlgetgid = undef,
$mysqldefaultgid = undef,
$mysqlgetdir = undef,
$mysqlforcetildeexpansion = undef,
$mysqlgetqtafs = undef,
$mysqlgetqtasz = undef,
$mysqlgetratioul = undef,
$mysqlgetratiodl = undef,
$mysqlgetbandwidthul = undef,
$mysqlgetbandwidthdl = undef,
) inherits pureftpd::params {

# options taken from pure-ftpd-1.0.30/configuration-file/log_mysql_p.h
$conf_options = [
'MYSQLServer',
'MYSQLPort',
'MYSQLSocket',
'MYSQLUser',
'MYSQLPassword',
'MYSQLDatabase',
'MYSQLCrypt',
'MYSQLTransactions',
'MYSQLGetPW',
'MYSQLGetUID',
'MYSQLDefaultUID',
'MYSQLGetGID',
'MYSQLDefaultGID',
'MYSQLGetDir',
'MYSQLForceTildeExpansion',
'MYSQLGetQTAFS',
'MYSQLGetQTASZ',
'MYSQLGetRatioUL',
'MYSQLGetRatioDL',
'MYSQLGetBandwidthUL',
'MYSQLGetBandwidthDL',
]

file { $pureftpd::params::mysql_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 @@ -23,7 +23,7 @@
$ldap_conf_erb = 'redhat/pure-ftpd.conf.erb'
$ldap_conf_path = "${config_dir}/pureftpd-ldap.conf"

$mysql_conf_erb = 'redhat/pureftpd-mysql.conf.erb'
$mysql_conf_erb = 'redhat/pure-ftpd.conf.erb'
$mysql_conf_path = "${config_dir}/pureftpd-mysql.conf"

$pgsql_conf_erb = 'redhat/pure-ftpd.conf.erb'
Expand Down
66 changes: 66 additions & 0 deletions spec/classes/config_mysql_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
require 'spec_helper'

test_options = [
'MYSQLServer',
'MYSQLPort',
'MYSQLSocket',
'MYSQLUser',
'MYSQLPassword',
'MYSQLDatabase',
'MYSQLCrypt',
'MYSQLTransactions',
'MYSQLGetPW',
'MYSQLGetUID',
'MYSQLDefaultUID',
'MYSQLGetGID',
'MYSQLDefaultGID',
'MYSQLGetDir',
'MYSQLForceTildeExpansion',
'MYSQLGetQTAFS',
'MYSQLGetQTASZ',
'MYSQLGetRatioUL',
'MYSQLGetRatioDL',
'MYSQLGetBandwidthUL',
'MYSQLGetBandwidthDL',
]

describe 'pureftpd::config::mysql' do

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

it do
should include_class('pureftpd::config::mysql')
should contain_file('/etc/pure-ftpd/pureftpd-mysql.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
130 changes: 0 additions & 130 deletions templates/redhat/pureftpd-mysql.conf.erb

This file was deleted.

0 comments on commit df44134

Please sign in to comment.