anchor { 'mailman3::core::end': }
class { '::mailman3::core::install':
- install_core => $install_core,
+ core_options => $core_options,
core_version => $core_version,
+ install_core => $install_core,
}
class { '::mailman3::core::config':
# Copyright 2015 Josh Farwell, unless otherwise noted.
#
class mailman3::core::install (
- $install_core,
+ $core_options,
$core_version,
+ $install_core,
) {
validate_bool($install_core)
+ validate_hash($core_options)
validate_string($core_version)
if ($install_core) {
require => Class['::mailman3::repo']
}
+ if has_key($core_options, 'database') {
+
+ validate_hash($core_options['database'])
+ unless has_key($core_options['database'], 'class') {
+ fail "Database options do not contain value for 'class'"
+ }
+
+ validate_string($core_options['database']['class'])
+
+ if ($core_options['database']['class'] == 'mailman.database.postgresql.PostgreSQLDatabase') {
+ package { 'python34-psycopg2':
+ ensure => present,
+ require => Class['::mailman3::repo']
+ }
+ }
+ }
+
+
}
}
{
'install_core' => true,
'core_version' => 'installed',
+ 'core_options' => {},
}
}
{
'install_core' => false,
'core_version' => 'installed',
+ 'core_options' => {},
}
}
end
+ context 'with a PostGresSQL database class in config' do
+
+ let(:params) {
+ {
+ 'install_core' => true,
+ 'core_version' => 'installed',
+ 'core_options' => {
+ 'database' => {
+ 'class' => 'mailman.database.postgresql.PostgreSQLDatabase',
+ },
+ },
+ }
+ }
+
+ it { is_expected.to contain_package('python-psycopg2') }
+ end
+
+ context 'with a non-Postgresql database in config' do
+
+ let(:params) {
+ {
+ 'install_core' => true,
+ 'core_version' => 'installed',
+ 'core_options' => {
+ 'database' => {
+ 'class' => 'mailman.database.sqlite.FakeConfig',
+ },
+ },
+ }
+ }
+
+ it { is_expected.to_not contain_package('python-psycopg2') }
+ end
end