Skip to content

Commit

Permalink
Updates on config and spec (#98)
Browse files Browse the repository at this point in the history
* Updates on config and spec

- on docker we must ensure that both paths are mounted (puppet_dir and
puppet_code_dir)
- add more spec tests

* Fix rubocop

* add spec test for image_tag
  • Loading branch information
tuxmea authored Nov 21, 2024
1 parent 8f17372 commit 9fa59e0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 9 deletions.
1 change: 1 addition & 0 deletions manifests/docker.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
volumes => [
"${hdm::hdm_path}:${hdm::hdm_path}",
"${hdm::puppet_dir}:${hdm::puppet_dir}:ro",
"${hdm::puppet_code_dir}:${hdm::puppet_code_dir}:ro",
"${hdm::hdm_path}/hdm.yml:/hdm/config/hdm.yml:ro",
"${hdm::hdm_path}/database.yml:/hdm/config/database.yml:ro",
],
Expand Down
43 changes: 34 additions & 9 deletions spec/classes/hdm_docker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,52 @@

describe 'hdm' do
on_supported_os.each do |os, os_facts|
let(:pre_condition) do
if facts[:os]['family'] == 'Suse'
'
class { "docker":
acknowledge_unsupported_os => true,
}
'
end
end

context "on #{os} using docker" do
let(:facts) { os_facts }
let(:params) do
{
'method' => 'docker',
'version' => '1.0.1',
'version' => '3.0.0',
}
end
let(:pre_condition) do
if facts[:os]['family'] == 'Suse'
'
class { "docker":
acknowledge_unsupported_os => true,
}
'
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('hdm::docker') }
it { is_expected.to contain_class('docker') }
it { is_expected.to contain_docker__image('ghcr.io/betadots/hdm').with('image_tag' => '3.0.0') }
it { is_expected.to contain_file('/etc/hdm') }
it { is_expected.to contain_file('/etc/hdm/certs') }
it { is_expected.to contain_file('/etc/hdm/db') }
it { is_expected.to contain_file('/etc/hdm/db/production.sqlite3') }
it { is_expected.to contain_file('/etc/hdm/database.yml') }
it { is_expected.to contain_file('/etc/hdm/hdm.yml').with('content' => %r{hiera_config_file: "hiera.yaml"}) }
end

context "on #{os} using docker with all parameters" do
let(:facts) { os_facts }
let(:params) do
{
'method' => 'docker',
'version' => '3.0.0',
'puppet_dir' => '/etc/puppetlabs',
'puppet_code_dir' => '/etc/puppet/code',
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('docker') }
it { is_expected.to contain_file('/etc/hdm/hdm.yml').with('content' => %r{hiera_config_file: "hiera.yaml"}) }
it { is_expected.to contain_docker__run('hdm').with('volumes' => %r{/etc/puppetlabs:/etc/puppetlabs:ro}) }
end
end
end
20 changes: 20 additions & 0 deletions spec/classes/hdm_rvm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('hdm::rvm') }
it { is_expected.to contain_rvm__system_user('hdm') }
it { is_expected.to contain_rvm_gem('bundler') }
it { is_expected.to contain_rvm_system_ruby('ruby-3.3.1') }
it { is_expected.to contain_group('hdm') }
it { is_expected.to contain_user('hdm') }
it { is_expected.to contain_vcsrepo('/etc/hdm') }
it { is_expected.to contain_file('/etc/hdm/config/hdm.yml') }
it { is_expected.to contain_exec('bundle config development') }
it { is_expected.to contain_exec('bundle config path') }
it { is_expected.to contain_exec('bundle db:setup') }
it { is_expected.to contain_exec('bundle install') }
it { is_expected.to contain_exec('bundle rails credentials') }
it { is_expected.to contain_systemd__unit_file('hdm.service') }

if os_facts[:os]['family'] == 'RedHat' && os_facts[:os]['release']['major'].to_i < 8
it { is_expected.to contain_package('centos-release-scl') }
it { is_expected.to contain_package('devtoolset-7') }
it { is_expected.to contain_exec('update sqlite') }
end
end
end
end

0 comments on commit 9fa59e0

Please sign in to comment.