Skip to content

Commit

Permalink
add unit tests and minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhollinger committed May 31, 2023
1 parent 48889b4 commit cf98ae5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ fixtures:
inifile: https://github.com/puppetlabs/puppetlabs-inifile.git
mcollective: https://github.com/choria-io/puppet-mcollective.git
ruby: https://github.com/puppetlabs/puppetlabs-ruby.git
stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git
systemd: https://github.com/voxpupuli/puppet-systemd.git
vcsrepo: https://github.com/puppetlabs/puppetlabs-vcsrepo.git
yumrepo_core: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
forge_modules:
stdlib:
repo: "puppetlabs/stdlib"
ref: "8.6.0"
mcollective_agent_filemgr: "choria/mcollective_agent_filemgr"
mcollective_agent_package: "choria/mcollective_agent_package"
mcollective_agent_puppet: "choria/mcollective_agent_puppet"
Expand Down
9 changes: 6 additions & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
$version = 'installed'
$manage_modulepath = false
$manage_ruby_dependency = 'ignore'
$root_user = 'root'
$root_group = 'root'

$provider = $facts['os']['name'] ? {
'Archlinux' => 'pacman',
Expand All @@ -26,6 +28,7 @@
$r10k_cache_dir = "${facts['puppet_vardir']}/r10k"
$r10k_config_file = '/etc/puppetlabs/r10k/r10k.yaml'
$r10k_binary = 'r10k'
$pre_postrun_command = "${r10k_binary} deploy environment -p"
$puppetconf_path = '/etc/puppetlabs/puppet'
$manage_configfile_symlink = false
$configfile_symlink = '/etc/r10k.yaml'
Expand Down Expand Up @@ -61,13 +64,13 @@
if fact('is_pe') == true or fact('is_pe') == 'true' {
# < PE 4
$is_pe_server = true
} elsif is_function_available('pe_compiling_server_version') {
# >= PE 4
$is_pe_server = true
$pe_module_path = '/opt/puppetlabs/puppet/modules'
$modulepath = "${r10k_basedir}/\$environment/modules:${pe_module_path}"
}
else {
# FOSS
$is_pe_server = false
$modulepath = "${r10k_basedir}/\$environment/modules"
}

# Webhook Go parameters
Expand Down
4 changes: 2 additions & 2 deletions manifests/webhook.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
port => $r10k::params::webhook_port,
tls => $tls,
},
R10k::Webhook::Config::R10k $r10k_settings = {
R10k::Webhook::Config::R10k $r10k = {
command_path => $r10k::params::webhook_r10k_command_path,
config_path => $r10k::params::webhook_r10k_config_path,
default_branch => $r10k::params::webhook_r10k_default_branch,
Expand All @@ -44,7 +44,7 @@
R10k::Webhook::Config $config = {
server => $server,
chatops => $chatops,
r10k => $r10k_settings,
r10k => $r10k,
},
) {
contain r10k::webhook::package
Expand Down
31 changes: 30 additions & 1 deletion spec/classes/webhook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
user: 'puppet',
password: 'puppet',
port: 4000,
tls: {
enabled: false,
}
},
r10k_settings: {
r10k: {
command_path: '/opt/puppetlabs/puppet/bin/r10k',
config_path: '/etc/puppetlabs/r10k/r10k.yaml',
default_branch: 'production',
Expand All @@ -40,10 +43,36 @@
}
}
end

content = '''---
server:
protected: true
user: puppet
password: puppet
port: 4000
tls:
enabled: false
chatops:
enabled: false
r10k:
command_path: "/opt/puppetlabs/puppet/bin/r10k"
config_path: "/etc/puppetlabs/r10k/r10k.yaml"
default_branch: production
allow_uppercase: false
verbose: true
deploy_modules: true
generate_types: true
'''
if os == 'archlinux-rolling-x86_64' || os == 'gentoo-2-x86_64'
it { is_expected.not_to compile }
else
it { is_expected.to compile }
it { is_expected.to contain_class('r10k::webhook::package') }
it { is_expected.to contain_class('r10k::webhook::service') }
it { is_expected.to contain_class('r10k::webhook::config') }
it { is_expected.to contain_package('webhook-go').with_ensure('present') }
it { is_expected.to contain_service('webhook').with_ensure('running') }
it { is_expected.to contain_file('webhook.yml').with_content(content) }
end
end
end
Expand Down

0 comments on commit cf98ae5

Please sign in to comment.